Fork HTTPClient and Modfiy code for mbed 6.0

Dependents:   mbed-demo-http-get-json

Committer:
WiredHome
Date:
Fri Mar 10 02:53:09 2017 +0000
Revision:
39:21fc7a4b6927
Child:
40:bcb19f8dbba3
Added an iCal interface to extract events on the fly, rather than requiring a big buffer.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 39:21fc7a4b6927 1 #ifndef HTTPICAL_H
WiredHome 39:21fc7a4b6927 2 #define HTTPICAL_H
WiredHome 39:21fc7a4b6927 3 #include <mbed.h>
WiredHome 39:21fc7a4b6927 4 #include "../IHTTPData.h"
WiredHome 39:21fc7a4b6927 5
WiredHome 39:21fc7a4b6927 6
WiredHome 39:21fc7a4b6927 7 /// An iCal handling mechanism - downloads and parses calendar events
WiredHome 39:21fc7a4b6927 8 class HTTPiCal : public IHTTPDataIn {
WiredHome 39:21fc7a4b6927 9
WiredHome 39:21fc7a4b6927 10 public:
WiredHome 39:21fc7a4b6927 11 #define SUMMARY_CHARS 100
WiredHome 39:21fc7a4b6927 12 #define LOCATION_CHARS 100
WiredHome 39:21fc7a4b6927 13 #define CATEGORY_CHARS 20
WiredHome 39:21fc7a4b6927 14 #define LINEBUFLEN 200
WiredHome 39:21fc7a4b6927 15
WiredHome 39:21fc7a4b6927 16 /// The repeat attribute for an event
WiredHome 39:21fc7a4b6927 17 typedef enum {
WiredHome 39:21fc7a4b6927 18 rptfNone, ///< no repeat for this event
WiredHome 39:21fc7a4b6927 19 rptfDaily, ///< daily repeat
WiredHome 39:21fc7a4b6927 20 rptfWeekly, ///< weekly repeat
WiredHome 39:21fc7a4b6927 21 rptfMonthly, ///< monthly repeat
WiredHome 39:21fc7a4b6927 22 rptfYearly ///< yearly repeat
WiredHome 39:21fc7a4b6927 23 } RepeatFreq_t;
WiredHome 39:21fc7a4b6927 24
WiredHome 39:21fc7a4b6927 25 typedef int32_t tz_sec_t;
WiredHome 39:21fc7a4b6927 26 typedef int16_t tz_min_t;
WiredHome 39:21fc7a4b6927 27
WiredHome 39:21fc7a4b6927 28 /// A single event consists of quite a number of attributes.
WiredHome 39:21fc7a4b6927 29 typedef struct {
WiredHome 39:21fc7a4b6927 30 time_t Start;
WiredHome 39:21fc7a4b6927 31 time_t End;
WiredHome 39:21fc7a4b6927 32 time_t Until;
WiredHome 39:21fc7a4b6927 33 uint16_t Count;
WiredHome 39:21fc7a4b6927 34 uint16_t Interval;
WiredHome 39:21fc7a4b6927 35 RepeatFreq_t RepeatFreq;
WiredHome 39:21fc7a4b6927 36 uint8_t RepeatDays; // bit mapped (bit 0 = sunday, bit 1=monday, ...)
WiredHome 39:21fc7a4b6927 37 uint16_t RepeatMonths; // bit mapped (bit 0 = jan, 1=feb, ...)
WiredHome 39:21fc7a4b6927 38 uint32_t RepeatMonthDay; // bit mapped (bit 1 = 1st, 2=2nd, ...)
WiredHome 39:21fc7a4b6927 39 uint32_t RepeatMonthDayRev; // reverse -1 = last day = bit 1, -2=bit 2, ...
WiredHome 39:21fc7a4b6927 40 char Summary[SUMMARY_CHARS];
WiredHome 39:21fc7a4b6927 41 char Location[LOCATION_CHARS];
WiredHome 39:21fc7a4b6927 42 char Category[CATEGORY_CHARS]; // "Green", ...
WiredHome 39:21fc7a4b6927 43 int Priority; // 1 == High, 5 == Normal, 9 == Low
WiredHome 39:21fc7a4b6927 44 } Event_T;
WiredHome 39:21fc7a4b6927 45
WiredHome 39:21fc7a4b6927 46
WiredHome 39:21fc7a4b6927 47 /// Instantiate HTTPiCal
WiredHome 39:21fc7a4b6927 48 ///
WiredHome 39:21fc7a4b6927 49 /// @code
WiredHome 39:21fc7a4b6927 50 /// HTTPClient http;
WiredHome 39:21fc7a4b6927 51 /// HTTPiCal iCal(10); // define a limit of 10 events to be held
WiredHome 39:21fc7a4b6927 52 ///
WiredHome 39:21fc7a4b6927 53 /// http.basicAuth(calInfo.user, calInfo.pass);
WiredHome 39:21fc7a4b6927 54 ///
WiredHome 39:21fc7a4b6927 55 /// time_t now = t.timelocal(); // Set a 4-hour window from now
WiredHome 39:21fc7a4b6927 56 /// time_t nxt = now + 4 * 3600;
WiredHome 39:21fc7a4b6927 57 /// ical.SetTimeWindow(now, nxt);
WiredHome 39:21fc7a4b6927 58 /// HTTPErrorCode = http.get(calInfo.url, &iCal);
WiredHome 39:21fc7a4b6927 59 /// if (HTTPErrorCode == HTTP_OK) {
WiredHome 39:21fc7a4b6927 60 /// // calendar successfully downloaded
WiredHome 39:21fc7a4b6927 61 /// for (int i=0; i<iCal.GetEventCount(); i++) {
WiredHome 39:21fc7a4b6927 62 /// HTTPiCal::Event_T event;
WiredHome 39:21fc7a4b6927 63 /// if (ical.GetEvent(i, &event)) {
WiredHome 39:21fc7a4b6927 64 /// printf("Event %d\r\n", i);
WiredHome 39:21fc7a4b6927 65 /// printf("Summary : %s\r\n", event.Summary);
WiredHome 39:21fc7a4b6927 66 /// printf("Location: %s\r\n", event.Location);
WiredHome 39:21fc7a4b6927 67 /// printf("Category: %s\r\n", event.Category);
WiredHome 39:21fc7a4b6927 68 /// }
WiredHome 39:21fc7a4b6927 69 /// }
WiredHome 39:21fc7a4b6927 70 /// }
WiredHome 39:21fc7a4b6927 71 /// @endcode
WiredHome 39:21fc7a4b6927 72 ///
WiredHome 39:21fc7a4b6927 73 /// @param count is the number of Event_T entries to reserve space for.
WiredHome 39:21fc7a4b6927 74 ///
WiredHome 39:21fc7a4b6927 75 HTTPiCal(int count);
WiredHome 39:21fc7a4b6927 76
WiredHome 39:21fc7a4b6927 77 /// Destructor to free memory
WiredHome 39:21fc7a4b6927 78 ~HTTPiCal();
WiredHome 39:21fc7a4b6927 79
WiredHome 39:21fc7a4b6927 80 /// Set the time window of interest, for which to retain events.
WiredHome 39:21fc7a4b6927 81 ///
WiredHome 39:21fc7a4b6927 82 /// This sets the time window of interest. Any event, whether directly
WiredHome 39:21fc7a4b6927 83 /// scheduled in this window, or indirectly via repeat attributes, will
WiredHome 39:21fc7a4b6927 84 /// be retained in the list of available events. Any event not in this
WiredHome 39:21fc7a4b6927 85 /// window will be ignored.
WiredHome 39:21fc7a4b6927 86 ///
WiredHome 39:21fc7a4b6927 87 /// @param StartTime is the optional time value for the beginning of
WiredHome 39:21fc7a4b6927 88 /// interest. If gridStartTime is zero, no filtering is performed.
WiredHome 39:21fc7a4b6927 89 /// @param EndTime is the optional time value ending the period of interest.
WiredHome 39:21fc7a4b6927 90 ///
WiredHome 39:21fc7a4b6927 91 void SetTimeWindow(time_t StartTime = 0, time_t EndTime = 0);
WiredHome 39:21fc7a4b6927 92
WiredHome 39:21fc7a4b6927 93 /// Get the count of Events currently available.
WiredHome 39:21fc7a4b6927 94 ///
WiredHome 39:21fc7a4b6927 95 /// @returns the count of events.
WiredHome 39:21fc7a4b6927 96 ///
WiredHome 39:21fc7a4b6927 97 int GetEventCount(void) { return EventCount; }
WiredHome 39:21fc7a4b6927 98
WiredHome 39:21fc7a4b6927 99 /// Get a copy of the specified event.
WiredHome 39:21fc7a4b6927 100 ///
WiredHome 39:21fc7a4b6927 101 /// @param i is the event number, ranging from 0 to GetEventCount()
WiredHome 39:21fc7a4b6927 102 /// @param event is a pointer to where the event will be copied.
WiredHome 39:21fc7a4b6927 103 /// @returns true if the event was available and copied.
WiredHome 39:21fc7a4b6927 104 ///
WiredHome 39:21fc7a4b6927 105 bool GetEvent(unsigned int i, Event_T * event);
WiredHome 39:21fc7a4b6927 106
WiredHome 39:21fc7a4b6927 107 protected:
WiredHome 39:21fc7a4b6927 108
WiredHome 39:21fc7a4b6927 109 friend class HTTPClient;
WiredHome 39:21fc7a4b6927 110
WiredHome 39:21fc7a4b6927 111 /** Reset stream to its beginning
WiredHome 39:21fc7a4b6927 112 * Called by the HTTPClient on each new request
WiredHome 39:21fc7a4b6927 113 */
WiredHome 39:21fc7a4b6927 114 virtual void writeReset();
WiredHome 39:21fc7a4b6927 115
WiredHome 39:21fc7a4b6927 116 /** Write a piece of data transmitted by the server
WiredHome 39:21fc7a4b6927 117 * @param[in] buf Pointer to the buffer from which to copy the data
WiredHome 39:21fc7a4b6927 118 * @param[in] len Length of the buffer
WiredHome 39:21fc7a4b6927 119 * @returns number of bytes written.
WiredHome 39:21fc7a4b6927 120 */
WiredHome 39:21fc7a4b6927 121 virtual int write(const char* buf, size_t len);
WiredHome 39:21fc7a4b6927 122
WiredHome 39:21fc7a4b6927 123 /** Set MIME type
WiredHome 39:21fc7a4b6927 124 * @param[in] type Internet media type from Content-Type header
WiredHome 39:21fc7a4b6927 125 */
WiredHome 39:21fc7a4b6927 126 virtual void setDataType(const char* type);
WiredHome 39:21fc7a4b6927 127
WiredHome 39:21fc7a4b6927 128 /** Determine whether the data is chunked
WiredHome 39:21fc7a4b6927 129 * Recovered from Transfer-Encoding header
WiredHome 39:21fc7a4b6927 130 * @param[in] chunked indicates the transfer is chunked.
WiredHome 39:21fc7a4b6927 131 */
WiredHome 39:21fc7a4b6927 132 virtual void setIsChunked(bool chunked);
WiredHome 39:21fc7a4b6927 133
WiredHome 39:21fc7a4b6927 134 /** If the data is not chunked, set its size
WiredHome 39:21fc7a4b6927 135 * From Content-Length header
WiredHome 39:21fc7a4b6927 136 * @param[in] len defines the size of the non-chunked transfer.
WiredHome 39:21fc7a4b6927 137 */
WiredHome 39:21fc7a4b6927 138 virtual void setDataLen(size_t len);
WiredHome 39:21fc7a4b6927 139
WiredHome 39:21fc7a4b6927 140 private:
WiredHome 39:21fc7a4b6927 141 char lineBuf[LINEBUFLEN]; ///< workspace to copy [partial] lines into
WiredHome 39:21fc7a4b6927 142
WiredHome 39:21fc7a4b6927 143 Event_T * EventList; ///< Pointer to the array of events
WiredHome 39:21fc7a4b6927 144 int EventSpaceCount; ///< Maximum number of events that can be tracked
WiredHome 39:21fc7a4b6927 145 int EventCount; ///< Current Count of events
WiredHome 39:21fc7a4b6927 146
WiredHome 39:21fc7a4b6927 147 time_t gridStartTime; ///< defines the start of the time window of interest
WiredHome 39:21fc7a4b6927 148 time_t gridEndTime; ///< defines the end of the time winedow of interest
WiredHome 39:21fc7a4b6927 149
WiredHome 39:21fc7a4b6927 150 int32_t tzoTZIDSec;
WiredHome 39:21fc7a4b6927 151 bool tzAdjusted;
WiredHome 39:21fc7a4b6927 152
WiredHome 39:21fc7a4b6927 153 typedef enum {
WiredHome 39:21fc7a4b6927 154 idle,
WiredHome 39:21fc7a4b6927 155 inTimeZone,
WiredHome 39:21fc7a4b6927 156 inEvent
WiredHome 39:21fc7a4b6927 157 } seekstate_t;
WiredHome 39:21fc7a4b6927 158 seekstate_t seeking;
WiredHome 39:21fc7a4b6927 159
WiredHome 39:21fc7a4b6927 160 #define min(a,b) (((a)<(b))?(a):(b))
WiredHome 39:21fc7a4b6927 161 #define max(a,b) (((a)>(b))?(a):(b))
WiredHome 39:21fc7a4b6927 162
WiredHome 39:21fc7a4b6927 163 /// Determine if a specific timestamp is in a leap year
WiredHome 39:21fc7a4b6927 164 ///
WiredHome 39:21fc7a4b6927 165 /// @param[in] t is the timestamp to evaluate
WiredHome 39:21fc7a4b6927 166 /// @returns true if the specified timestamp is within a leap year
WiredHome 39:21fc7a4b6927 167 ///
WiredHome 39:21fc7a4b6927 168 bool isLeapYear(time_t t);
WiredHome 39:21fc7a4b6927 169
WiredHome 39:21fc7a4b6927 170 /// Inspect the event to determine if its repeat attribute places it in the specified time window
WiredHome 39:21fc7a4b6927 171 ///
WiredHome 39:21fc7a4b6927 172 /// @param[in] start1 represents the start of the timerange of interest.
WiredHome 39:21fc7a4b6927 173 /// @param[in] end1 is the time range representing the end of the range of interest
WiredHome 39:21fc7a4b6927 174 /// @param[in] start2 is the time range of the event being tested
WiredHome 39:21fc7a4b6927 175 /// @param[in] end2 is the time range of the event being tested
WiredHome 39:21fc7a4b6927 176 /// @param[in] Event is a pointer to the event being tested and permits testing the repeat information.
WiredHome 39:21fc7a4b6927 177 /// @returns true if the event repeat pattern intersects with the display pattern
WiredHome 39:21fc7a4b6927 178 ///
WiredHome 39:21fc7a4b6927 179 bool RepeatMaskIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2, Event_T * Event);
WiredHome 39:21fc7a4b6927 180
WiredHome 39:21fc7a4b6927 181 /// Convert 'n' characters in a string to an unsigned integer.
WiredHome 39:21fc7a4b6927 182 ///
WiredHome 39:21fc7a4b6927 183 /// @param[in] p is a pointer to the string.
WiredHome 39:21fc7a4b6927 184 /// @param[in] n is the number of characters to convert.
WiredHome 39:21fc7a4b6927 185 /// @returns an unsigned integer of the converted value.
WiredHome 39:21fc7a4b6927 186 ///
WiredHome 39:21fc7a4b6927 187 uint16_t AtoIxN(const char * p, int n);
WiredHome 39:21fc7a4b6927 188
WiredHome 39:21fc7a4b6927 189 /// Parse some information from the stream and extract event information.
WiredHome 39:21fc7a4b6927 190 ///
WiredHome 39:21fc7a4b6927 191 /// @param[in] Event is a pointer to the current event to populate.
WiredHome 39:21fc7a4b6927 192 /// @param[in] pStart is a pointer to the start of a text stream to evaluate.
WiredHome 39:21fc7a4b6927 193 /// @param[in] tzoSec is the time zone offset in seconds.
WiredHome 39:21fc7a4b6927 194 ///
WiredHome 39:21fc7a4b6927 195 void ParseEvent(Event_T * Event, const char * pStart, tz_sec_t tzoSec);
WiredHome 39:21fc7a4b6927 196
WiredHome 39:21fc7a4b6927 197
WiredHome 39:21fc7a4b6927 198 /// Prepare to start processing an iCal stream
WiredHome 39:21fc7a4b6927 199 ///
WiredHome 39:21fc7a4b6927 200 /// This initializes the data structures for parsing.
WiredHome 39:21fc7a4b6927 201 ///
WiredHome 39:21fc7a4b6927 202 /// @code
WiredHome 39:21fc7a4b6927 203 /// ParseICalStart();
WiredHome 39:21fc7a4b6927 204 /// while (receive(buf, ... ))
WiredHome 39:21fc7a4b6927 205 /// ParseICalStream(buf, ...);
WiredHome 39:21fc7a4b6927 206 /// count = ParseICalClose();
WiredHome 39:21fc7a4b6927 207 /// @endcode
WiredHome 39:21fc7a4b6927 208 ///
WiredHome 39:21fc7a4b6927 209 void ParseICalStart(void);
WiredHome 39:21fc7a4b6927 210
WiredHome 39:21fc7a4b6927 211
WiredHome 39:21fc7a4b6927 212 /// End processing an iCal stream and return the number of events
WiredHome 39:21fc7a4b6927 213 ///
WiredHome 39:21fc7a4b6927 214 /// @returns number of events in range
WiredHome 39:21fc7a4b6927 215 ///
WiredHome 39:21fc7a4b6927 216 int ParseICalClose(void);
WiredHome 39:21fc7a4b6927 217
WiredHome 39:21fc7a4b6927 218
WiredHome 39:21fc7a4b6927 219 /// Parse an iCal stream, and extract everything useful.
WiredHome 39:21fc7a4b6927 220 ///
WiredHome 39:21fc7a4b6927 221 /// This accepts a pointer to a [large] buffer, which is the contents
WiredHome 39:21fc7a4b6927 222 /// of an iCal stream. It walked through all of the available
WiredHome 39:21fc7a4b6927 223 /// information to extract the Event list.
WiredHome 39:21fc7a4b6927 224 ///
WiredHome 39:21fc7a4b6927 225 /// @param[in] pStart is a pointer to the start of the stream.
WiredHome 39:21fc7a4b6927 226 /// @param[in] gridStartTime is a time value representing the start of the time-window of interest.
WiredHome 39:21fc7a4b6927 227 /// @param[in] gridEndTime is a time value representing the end of the time-window of interest.
WiredHome 39:21fc7a4b6927 228 /// @param[in] tzoMin is the time-zone offset in minutes.
WiredHome 39:21fc7a4b6927 229 /// @param[in] showEvents when true causes it to print the events as parsed.
WiredHome 39:21fc7a4b6927 230 /// @returns number of events in range.
WiredHome 39:21fc7a4b6927 231 ///
WiredHome 39:21fc7a4b6927 232 int ParseICalStream(const char * pStart, time_t gridStartTime, time_t gridEndTime, tz_min_t tzoMin, bool showEvents = true);
WiredHome 39:21fc7a4b6927 233
WiredHome 39:21fc7a4b6927 234
WiredHome 39:21fc7a4b6927 235 /// Get the number of events that have been cached.
WiredHome 39:21fc7a4b6927 236 ///
WiredHome 39:21fc7a4b6927 237 /// @returns the number of events.
WiredHome 39:21fc7a4b6927 238 ///
WiredHome 39:21fc7a4b6927 239 int GetNumEvents(void);
WiredHome 39:21fc7a4b6927 240
WiredHome 39:21fc7a4b6927 241 /// Compute if the referenced event occurs within the specified time window.
WiredHome 39:21fc7a4b6927 242 ///
WiredHome 39:21fc7a4b6927 243 /// @param[in] startWindow is the starting timestamp.
WiredHome 39:21fc7a4b6927 244 /// @param[in] endWindow is the ending timestamp.
WiredHome 39:21fc7a4b6927 245 /// @param[in] Event is a pointer to the event, which can have repeat rules.
WiredHome 39:21fc7a4b6927 246 /// @returns true if the event laps into the current time window.
WiredHome 39:21fc7a4b6927 247 ///
WiredHome 39:21fc7a4b6927 248 bool EventIntersects(time_t startWindow, time_t endWindow, Event_T * Event);
WiredHome 39:21fc7a4b6927 249
WiredHome 39:21fc7a4b6927 250 /// Compute the intersection of two time ranges, and evaluate the recurringing events.
WiredHome 39:21fc7a4b6927 251 ///
WiredHome 39:21fc7a4b6927 252 /// This compares a pair of time ranges, each by a start and end time. If they overlap
WiredHome 39:21fc7a4b6927 253 /// it then computes the intersection of those two ranges. Additionally, for a
WiredHome 39:21fc7a4b6927 254 /// specified Event, it will evaluate the recurring events that may also fall into
WiredHome 39:21fc7a4b6927 255 /// the target time range.
WiredHome 39:21fc7a4b6927 256 ///
WiredHome 39:21fc7a4b6927 257 /// @note This is usually the only API you need, as this will first call
WiredHome 39:21fc7a4b6927 258 /// the TimeIntersects function, and if that fails, then it will evaluate
WiredHome 39:21fc7a4b6927 259 /// repeat information.
WiredHome 39:21fc7a4b6927 260 ///
WiredHome 39:21fc7a4b6927 261 /// @param[in,out] start1 is the starting time of range 1.
WiredHome 39:21fc7a4b6927 262 /// @param[in,out] end1 is the ending time of range 1.
WiredHome 39:21fc7a4b6927 263 /// @param[in] start2 is the starting time of range 2.
WiredHome 39:21fc7a4b6927 264 /// @param[in] end2 is the ending time of range 2.
WiredHome 39:21fc7a4b6927 265 /// @param[in] Event is a pointer to the event of interest that may have recurring series.
WiredHome 39:21fc7a4b6927 266 /// @returns true if the ranges overlap, and then start1 and end1 are set to the
WiredHome 39:21fc7a4b6927 267 /// intersection.
WiredHome 39:21fc7a4b6927 268 ///
WiredHome 39:21fc7a4b6927 269 bool RepeatIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2, Event_T * Event = NULL);
WiredHome 39:21fc7a4b6927 270
WiredHome 39:21fc7a4b6927 271
WiredHome 39:21fc7a4b6927 272 /// Compute the intersection of two time ranges, and returns that intersection.
WiredHome 39:21fc7a4b6927 273 ///
WiredHome 39:21fc7a4b6927 274 /// This compares a pair of time ranges, each by a start and end time. If they overlap
WiredHome 39:21fc7a4b6927 275 /// it then computes the intersection of those two ranges.
WiredHome 39:21fc7a4b6927 276 ///
WiredHome 39:21fc7a4b6927 277 /// @param[in,out] start1 is the starting time of range 1.
WiredHome 39:21fc7a4b6927 278 /// @param[in,out] end1 is the ending time of range 1.
WiredHome 39:21fc7a4b6927 279 /// @param[in] start2 is the starting time of range 2.
WiredHome 39:21fc7a4b6927 280 /// @param[in] end2 is the ending time of range 2.
WiredHome 39:21fc7a4b6927 281 /// @returns true if the ranges overlap, and then start1 and end1 are set to the
WiredHome 39:21fc7a4b6927 282 /// intersection.
WiredHome 39:21fc7a4b6927 283 ///
WiredHome 39:21fc7a4b6927 284 bool TimeIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2);
WiredHome 39:21fc7a4b6927 285
WiredHome 39:21fc7a4b6927 286
WiredHome 39:21fc7a4b6927 287 // Private Functions - no real value external to the iCal public interface
WiredHome 39:21fc7a4b6927 288 // other than for test code.
WiredHome 39:21fc7a4b6927 289
WiredHome 39:21fc7a4b6927 290 /// Computes the next interval for iCal events that have recurrence.
WiredHome 39:21fc7a4b6927 291 ///
WiredHome 39:21fc7a4b6927 292 /// @param[in] baseT is the base time value which is a factor only in leap-year.
WiredHome 39:21fc7a4b6927 293 /// @param[in] repeatFreq is a value representing the frequency of recurrence -
WiredHome 39:21fc7a4b6927 294 /// 0=none, 1=daily, 2=weekly, 3=monthly, 4=yearly
WiredHome 39:21fc7a4b6927 295 /// @param[in] interval is the multiplier of that repeat frequency to the next
WiredHome 39:21fc7a4b6927 296 /// event.
WiredHome 39:21fc7a4b6927 297 /// @returns a time_t value which is the incremental interval, and would be added
WiredHome 39:21fc7a4b6927 298 /// to a reference time.
WiredHome 39:21fc7a4b6927 299 ///
WiredHome 39:21fc7a4b6927 300 time_t NextInterval(time_t baseT, int repeatFreq, int interval);
WiredHome 39:21fc7a4b6927 301
WiredHome 39:21fc7a4b6927 302
WiredHome 39:21fc7a4b6927 303 /// Format a ctime value as a string, without the trailing <cr>
WiredHome 39:21fc7a4b6927 304 ///
WiredHome 39:21fc7a4b6927 305 /// This uses the normal ctime function, which appends a <cr>, but
WiredHome 39:21fc7a4b6927 306 /// it then removes that trailing line ending character. Additionally,
WiredHome 39:21fc7a4b6927 307 /// this keeps a few local static buffers to return the time string in
WiredHome 39:21fc7a4b6927 308 /// which permits a printf (for example) to call this api a few times
WiredHome 39:21fc7a4b6927 309 /// and get the proper representation of each.
WiredHome 39:21fc7a4b6927 310 ///
WiredHome 39:21fc7a4b6927 311 /// @param[in] t is a time value;
WiredHome 39:21fc7a4b6927 312 /// @returns a pointer to a static buffer containing the converted time.
WiredHome 39:21fc7a4b6927 313 ///
WiredHome 39:21fc7a4b6927 314 char * FormatCTime(time_t t);
WiredHome 39:21fc7a4b6927 315
WiredHome 39:21fc7a4b6927 316 /// Sort the Events that have been extracted from the iCal results.
WiredHome 39:21fc7a4b6927 317 ///
WiredHome 39:21fc7a4b6927 318 void SortEvents();
WiredHome 39:21fc7a4b6927 319
WiredHome 39:21fc7a4b6927 320 /// Show the details for a specific Event, on the specified serial stream.
WiredHome 39:21fc7a4b6927 321 ///
WiredHome 39:21fc7a4b6927 322 /// Most useful during development, and perhaps no value after that.
WiredHome 39:21fc7a4b6927 323 ///
WiredHome 39:21fc7a4b6927 324 /// @param[in] Event is the event of interest.
WiredHome 39:21fc7a4b6927 325 ///
WiredHome 39:21fc7a4b6927 326 void ShowEventInfo(Event_T & Event);
WiredHome 39:21fc7a4b6927 327
WiredHome 39:21fc7a4b6927 328 /// Access the 2-letter abbreviation for the day of the week.
WiredHome 39:21fc7a4b6927 329 ///
WiredHome 39:21fc7a4b6927 330 /// @param[in] i is the day of the week, where 0 = sunday
WiredHome 39:21fc7a4b6927 331 /// @returns a pointer to the 2-letter abbreviation.
WiredHome 39:21fc7a4b6927 332 ///
WiredHome 39:21fc7a4b6927 333 const char * RepeatDayAbbrev(int i);
WiredHome 39:21fc7a4b6927 334
WiredHome 39:21fc7a4b6927 335 /// Parse a Datestamp string into a time value.
WiredHome 39:21fc7a4b6927 336 ///
WiredHome 39:21fc7a4b6927 337 /// Parses a string which can look like this: 20140505T200000
WiredHome 39:21fc7a4b6927 338 /// into a time_t value.
WiredHome 39:21fc7a4b6927 339 ///
WiredHome 39:21fc7a4b6927 340 /// @param[in] string is the string to parse.
WiredHome 39:21fc7a4b6927 341 /// @param[in] tzoSec is the time-zone offset in seconds.
WiredHome 39:21fc7a4b6927 342 /// @returns time_t value.
WiredHome 39:21fc7a4b6927 343 ///
WiredHome 39:21fc7a4b6927 344 time_t ParseDateStamp(const char * string, tz_sec_t tzoSec);
WiredHome 39:21fc7a4b6927 345
WiredHome 39:21fc7a4b6927 346 /// Parse a Time Zone ID value from the front-end of a Datestamp
WiredHome 39:21fc7a4b6927 347 ///
WiredHome 39:21fc7a4b6927 348 /// Parses a string which can look like one of these:
WiredHome 39:21fc7a4b6927 349 /// @li TZID="(GMT -06:00)":20140519T063000
WiredHome 39:21fc7a4b6927 350 /// @li TZID:(UTC-06:00) Central Time (US & Canada)
WiredHome 39:21fc7a4b6927 351 /// @li TZID:(GMT -06:00)
WiredHome 39:21fc7a4b6927 352 ///
WiredHome 39:21fc7a4b6927 353 /// @param[in] string to be parsed.
WiredHome 39:21fc7a4b6927 354 /// @returns time zone offset in seconds.
WiredHome 39:21fc7a4b6927 355 ///
WiredHome 39:21fc7a4b6927 356 tz_sec_t ParseTZID(const char * string);
WiredHome 39:21fc7a4b6927 357
WiredHome 39:21fc7a4b6927 358
WiredHome 39:21fc7a4b6927 359 bool m_chunked;
WiredHome 39:21fc7a4b6927 360 };
WiredHome 39:21fc7a4b6927 361 #endif // HTTPICAL_H