#include "http-url.h"
#include "ioloop.h"
#include "istream.h"
+#include "settings-parser.h"
#include "json-parser.h"
#include "mailbox-attribute.h"
#include "mail-storage-private.h"
/* Default values. */
static const char *const default_events[] = { "MessageNew", NULL };
static const char *const default_mboxes[] = { "INBOX", NULL };
-#define DEFAULT_CACHE_LIFETIME 60
+#define DEFAULT_CACHE_LIFETIME_SECS 60
#define DEFAULT_TIMEOUT_MSECS 2000
#define DEFAULT_RETRY_COUNT 1
/* This is data specific to an OX driver. */
struct push_notification_driver_ox_config {
struct http_url *http_url;
- unsigned int cached_ox_metadata_lifetime;
+ unsigned int cached_ox_metadata_lifetime_secs;
bool use_unsafe_username;
unsigned int http_max_retries;
unsigned int http_timeout_msecs;
push_notification_driver_debug(OX_LOG_LABEL, user, "Using URL %s", tmp);
tmp = hash_table_lookup(config->config, (const char *)"cache_lifetime");
- if ((tmp == NULL) ||
- (str_to_uint(tmp, &dconfig->cached_ox_metadata_lifetime) < 0)) {
- dconfig->cached_ox_metadata_lifetime = DEFAULT_CACHE_LIFETIME;
+ if (tmp == NULL)
+ dconfig->cached_ox_metadata_lifetime_secs = DEFAULT_CACHE_LIFETIME_SECS;
+ else if (settings_get_time(tmp, &dconfig->cached_ox_metadata_lifetime_secs, &error) < 0) {
+ *error_r = t_strdup_printf(OX_LOG_LABEL "Failed to parse OX cache_lifetime %s: %s",
+ tmp, error);
+ return -1;
}
tmp = hash_table_lookup(config->config, (const char *)"max_retries");
push_notification_driver_debug(OX_LOG_LABEL, user,
"Using cache lifetime: %u",
- dconfig->cached_ox_metadata_lifetime);
+ dconfig->cached_ox_metadata_lifetime_secs);
if (ox_global == NULL) {
ox_global = i_new(struct push_notification_driver_ox_global, 1);
int ret;
if ((dconfig->cached_ox_metadata != NULL) &&
- ((dconfig->cached_ox_metadata_timestamp + (time_t)dconfig->cached_ox_metadata_lifetime) > ioloop_time)) {
+ ((dconfig->cached_ox_metadata_timestamp +
+ (time_t)dconfig->cached_ox_metadata_lifetime_secs) > ioloop_time)) {
return dconfig->cached_ox_metadata;
}