OpenAB::PIMItem::Revision EDSCalendarStorage::getRevision(const OpenAB::PIMItem::ID& id)
{
  OpenAB::PIMItem::Revision revision;
  GError* gerror = NULL;
  GSList* events = NULL;
  std::vector<icalcomponent*> iCalComponents;

  if (!e_cal_client_get_objects_for_uid_sync(client, id.c_str(), &events, NULL, &gerror))
  {
    LOG_ERROR() << "Error e_cal_client_get_objects_for_uid_sync result: " << GERROR_MESSAGE(gerror) << std::endl;
    GERROR_FREE(gerror);
    return "";
  }

  GSList* current = events;
  //in case of recurring event, create revision as concatnation of single revision of all event instances,
  //so even if only on instance will be modified then we will be able to detect that whole event needs to be updated.
  while(current)
  {
    ECalComponent* component = (ECalComponent*)current->data;
    icalcomponent* iCalComponent =  e_cal_component_get_icalcomponent(component);
    revision += icaltime_as_ical_string(icalcomponent_get_dtstamp(iCalComponent));
    current = current->next;
  }

  e_cal_client_free_ecalcomp_slist(events);

  return revision;
}
Exemplo n.º 2
0
NS_IMETHODIMP
calDateTime::GetIcalString(nsACString& aResult)
{
    icaltimetype t;
    ToIcalTime(&t);

    // note that ics is owned by libical, so we don't need to free
    char const * const ics = icaltime_as_ical_string(t);
    CAL_ENSURE_MEMORY(ics);
    aResult.Assign(ics);
    return NS_OK;
}
static void
objects_modified_cb (GObject *object,
                     const GSList *objects,
                     gpointer data)
{
	const GSList *l;
	GMainLoop *loop = (GMainLoop *) data;

	for (l = objects; l; l = l->next) {
		icalcomponent      *component     = l->data;
		struct icaltimetype recurrence    = icalcomponent_get_recurrenceid (component);
		struct icaltimetype last_modified = get_last_modified (component);

		g_print (
			"Object modified %s (recurrence id:%s, last-modified:%s)\n",
			icalcomponent_get_uid (component),
			icaltime_as_ical_string (recurrence),
			icaltime_as_ical_string (last_modified));

		g_assert (icalcomponent_get_summary (component) == NULL);
	}

	subtest_passed (SUBTEST_OBJECTS_MODIFIED, loop);
}
static char *
get_ical_rid (icalcomponent *ical)
{
  icalproperty        *prop;
  struct icaltimetype  ical_time;

  prop = icalcomponent_get_first_property (ical, ICAL_RECURRENCEID_PROPERTY);
  if (!prop)
    return NULL;

  ical_time = icalproperty_get_recurrenceid (prop);

  return icaltime_is_valid_time (ical_time) && !icaltime_is_null_time (ical_time) ?
    g_strdup (icaltime_as_ical_string (ical_time)) : NULL;
}
Exemplo n.º 5
0
/** Store timestamp of last sync.
 *
 * @param cb 3E calendar backend.
 * @param stamp Timestamp in local time.
 */
void e_cal_backend_3e_set_sync_timestamp(ECalBackend3e *cb, time_t stamp)
{
    g_static_rw_lock_writer_lock(&cb->priv->cache_lock);
    e_cal_backend_cache_put_server_utc_time(cb->priv->cache, icaltime_as_ical_string(icaltime_from_timet_with_zone(stamp, 0, NULL)));
    g_static_rw_lock_writer_unlock(&cb->priv->cache_lock);
}
Exemplo n.º 6
0
icalproperty *icalproperty_new_tzuntil(struct icaltimetype v)
{
    icalproperty *prop = icalproperty_new_x(icaltime_as_ical_string(v));
    icalproperty_set_x_name(prop, "TZUNTIL");
    return prop;
}
Exemplo n.º 7
0
void
e_sendoptions_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *comp)
{
	int i = 1;
	icalproperty *prop;
	icalcomponent *icalcomp;
	ESendOptionsGeneral *gopts;
	ESendOptionsStatusTracking *sopts;

	gopts = sod->data->gopts;
	sopts = sod->data->sopts;

	e_cal_component_set_sequence (comp, &i);
	icalcomp = e_cal_component_get_icalcomponent (comp);

	if (e_sendoptions_get_need_general_options (sod)) {
		prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", gopts->priority));
		icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-PRIORITY");
		icalcomponent_add_property (icalcomp, prop);

		if (gopts->reply_enabled) {
			if (gopts->reply_convenient)
				prop = icalproperty_new_x ("convenient");
			else
				prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", gopts->reply_within));
			icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-REPLY");
			icalcomponent_add_property (icalcomp, prop);
		}

		if (gopts->expiration_enabled && gopts->expire_after) {
			prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", gopts->expire_after));
			icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-EXPIRE");
			icalcomponent_add_property (icalcomp, prop);
		}

		if (gopts->delay_enabled) {
			struct icaltimetype temp;
			char *str;

			icaltimezone *zone = calendar_config_get_icaltimezone ();
			temp = icaltime_from_timet_with_zone (gopts->delay_until, FALSE, zone);

			str = icaltime_as_ical_string (temp);
			prop = icalproperty_new_x (str);
			g_free (str);
			icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DELAY");
			icalcomponent_add_property (icalcomp, prop);
		}
	}

	if (sopts->tracking_enabled)
		prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", sopts->track_when));
	else
		prop = icalproperty_new_x ("0");

	icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-TRACKINFO");
	icalcomponent_add_property (icalcomp, prop);


	prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->opened));
	icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-OPENED");
	icalcomponent_add_property (icalcomp, prop);

	prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->accepted));
	icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-ACCEPTED");
	icalcomponent_add_property (icalcomp, prop);

	prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->declined));
	icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DECLINED");
	icalcomponent_add_property (icalcomp, prop);

	prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->completed));
	icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-COMPLETED");
	icalcomponent_add_property (icalcomp, prop);
}