コード例 #1
0
/**
 * e_cal_tzlookup_ecal:
 * @tzid: ID of the timezone to lookup
 * @custom: must be a valid #ECal pointer
 * @error: an error description in case of a failure
 *
 * An implementation of the tzlookup callback which clients
 * can use. Calls e_cal_get_timezone().
 *
 * Returns: A timezone object, or %NULL on failure. This object is owned
 *   by the @custom, thus do not free it.
 *
 * Since: 2.24
 *
 * Deprecated: 3.2: Use e_cal_client_tzlookup() instead.
 */
icaltimezone *
e_cal_tzlookup_ecal (const gchar *tzid,
                     gconstpointer custom,
                     GError **error)
{
	ECal *ecal = (ECal *) custom;
	icaltimezone *zone = NULL;
	GError *local_error = NULL;

	g_return_val_if_fail (ecal != NULL, NULL);
	g_return_val_if_fail (E_IS_CAL (ecal), NULL);

	if (e_cal_get_timezone (ecal, tzid, &zone, &local_error)) {
		g_warn_if_fail (local_error == NULL);
		return zone;
	}

	if (g_error_matches (local_error, E_CALENDAR_ERROR,
		E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) {
		/* We had to trigger this error to check for the
		 * timezone existance, clear it and return NULL. */
		g_clear_error (&local_error);
	}

	g_propagate_error (error, local_error);

	return NULL;
}
コード例 #2
0
static gchar *
test_timezones (ECal *client)
{
	icaltimezone *zone;
	GError *error = NULL;
	if (!e_cal_get_timezone (client, "UTC", &zone, &error))
	{
		cl_printf (client, "Could not get the timezone\n");
	}

	printf ("\n\nTime Zones : \n%s *** %s", icaltimezone_get_display_name (zone), icaltimezone_get_tzid (zone));
	printf ("\n\nTime Zones : \n%s", icaltimezone_get_location (zone));

	return NULL;
}
コード例 #3
0
/**
 * e_cal_tzlookup_ecal:
 * @custom: must be a valid ECal pointer
 *
 * An implementation of the tzlookup callback which clients
 * can use. Calls #e_cal_get_timezone.
 */
icaltimezone *e_cal_tzlookup_ecal(const char *tzid,
                                  const void *custom,
                                  GError **error)
{
    ECal *ecal = (ECal *)custom;
    icaltimezone *zone = NULL;

    if (e_cal_get_timezone(ecal, tzid, &zone, error)) {
        g_assert(*error == NULL);
        return zone;
    } else {
        g_assert(*error);
        if ((*error)->domain == E_CALENDAR_ERROR &&
            ((*error)->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND /* EDS < 2.30 */ ||
             (*error)->code == E_CALENDAR_STATUS_INVALID_OBJECT /* EDS >= 2.30 */ )) {
            /*
             * we had to trigger this error to check for the timezone existance,
             * clear it and return NULL
             */
            g_clear_error(error);
        }
        return NULL;
    }
}