/* Generated file (by generator) */

/*
 * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "i-cal-vcard-tz.h"
#include "libical-glib-private.h"

G_DEFINE_TYPE (ICalVcardTz, i_cal_vcard_tz, I_CAL_TYPE_OBJECT)

static void i_cal_vcard_tz_class_init (G_GNUC_UNUSED ICalVcardTzClass *klass)
{
}

static void i_cal_vcard_tz_init (G_GNUC_UNUSED ICalVcardTz *self)
{
}

/**
 * i_cal_vcard_tz_new_full: (skip)
 * @native: The native libical object.
 *
 * Create a new libical-glib object from the native libical object and the owner.
 *
 * Returns: (transfer full): The newly create libical-glib object.
 *
 * Since: 1.0
 **/
ICalVcardTz *
i_cal_vcard_tz_new_full (vcardtztype native)
{
    ICalVcardTz *object;
    vcardtztype *clone;
    
    
    clone = g_new (vcardtztype, 1);
    *clone = native;
    object = i_cal_object_construct (I_CAL_VCARD_TYPE_TZ,
                            (gpointer) clone,
                            (GDestroyNotify) g_free,
                            FALSE,
                            NULL);

    return object;
}


    #define TZ_KEY_TZID "i-cal-vcard-tz-key-tzid"
    #define TZ_KEY_URI "i-cal-vcard-tz-key-uri"
	

/**
 * priv_i_cal_vcard_null_tz: (skip)
 *
 * Returns null/empty vcardtztype structure.
 *
 * Returns: null/empty vcardtztype structure
 *
 * Since: 1.0
 *
 **/
vcardtztype
priv_i_cal_vcard_null_tz (void)
{
vcardtztype tz = { 0, };
    return tz;
}

/**
 * i_cal_vcard_tz_new_tzid:
 * @tzid: The timezone ID
 *
 * Creates a new #ICalVcardTz holding the TZID value.
 *
 * Returns: (transfer full): The newly created #ICalVcardTz holding the TZID value
 *
 * Since: 4.0
 *
 **/
ICalVcardTz *
i_cal_vcard_tz_new_tzid (const gchar *tzid)
{
    vcardtztype tz = { 0, };
    gchar *tzid_copy = g_strdup(tzid);
    ICalVcardTz *obj;
    tz.tzid = tzid_copy;
    obj = i_cal_vcard_tz_new_full(tz);
    g_object_set_data_full(G_OBJECT(obj), TZ_KEY_TZID, tzid_copy, g_free);
    return obj;
}

/**
 * i_cal_vcard_tz_new_uri:
 * @uri: The URI value for the TZ
 *
 * Creates a new #ICalVcardTz holding the URI value.
 *
 * Returns: (transfer full): The newly created #ICalVcardTz holding the URI value
 *
 * Since: 4.0
 *
 **/
ICalVcardTz *
i_cal_vcard_tz_new_uri (const gchar *uri)
{
    vcardtztype tz = { 0, };
    gchar *uri_copy = g_strdup(uri);
    ICalVcardTz *obj;
    tz.uri = uri_copy;
    obj = i_cal_vcard_tz_new_full(tz);
    g_object_set_data_full(G_OBJECT(obj), TZ_KEY_URI, uri_copy, g_free);
    return obj;
}

/**
 * i_cal_vcard_tz_new_utc_offset:
 * @utc_offset: a UTC offset
 *
 * Creates a new #ICalVcardTz holding the UTC offset.
 *
 * Returns: (transfer full): The newly created #ICalVcardTz holding the UTC offset
 *
 * Since: 4.0
 *
 **/
ICalVcardTz *
i_cal_vcard_tz_new_utc_offset (gint utc_offset)
{
    vcardtztype tz = { 0, };
    tz.utcoffset = utc_offset;
    return i_cal_vcard_tz_new_full(tz);
}

/**
 * i_cal_vcard_tz_clone:
 * @self: The #ICalVcardTz to clone
 *
 * Creates a new #ICalVcardTz, copy of @self.
 *
 * Returns: (transfer full): The newly created #ICalVcardTz, copy of @self.
 *
 * Since: 4.0
 *
 **/
ICalVcardTz *
i_cal_vcard_tz_clone (const ICalVcardTz *self)
{
    vcardtztype *tt, tz;
    gchar *tzid_copy = NULL, *uri_copy = NULL;
    ICalVcardTz *obj;

    g_return_val_if_fail(I_CAL_VCARD_IS_TZ((ICalVcardTz *)self), NULL);

    tt = (vcardtztype *)i_cal_object_get_native((ICalObject *)self);
    g_return_val_if_fail(tt != NULL, NULL);

    tz = *tt;
    tzid_copy = g_strdup(tz.tzid);
    uri_copy = g_strdup(tz.uri);
    tz.tzid = tzid_copy;
    tz.uri = uri_copy;
    obj = i_cal_vcard_tz_new_full(tz);
    g_object_set_data_full(G_OBJECT(obj), TZ_KEY_TZID, tzid_copy, g_free);
    g_object_set_data_full(G_OBJECT(obj), TZ_KEY_URI, uri_copy, g_free);
    return obj;
}

/**
 * i_cal_vcard_tz_get_tzid:
 * @self: an #ICalVcardTz
 *
 * Gets the timezone ID value of the @self. It can return %NULL when not set or when the @self is not of
 * type timezone ID.
 *
 * Returns: (nullable): a URI
 *
 * Since: 4.0
 *
 **/
const gchar *
i_cal_vcard_tz_get_tzid (const ICalVcardTz *self)
{
    g_return_val_if_fail(I_CAL_VCARD_IS_TZ((ICalVcardTz *)self), NULL);
    return ((vcardtztype *)i_cal_object_get_native((ICalObject *)self))->tzid;
}

/**
 * i_cal_vcard_tz_set_tzid:
 * @self: an #ICalVcardTz
 * @tzid: a URI
 *
 * Sets the URI value of the @self.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_tz_set_tzid (ICalVcardTz *self, 
                         const gchar *tzid)
{
    vcardtztype *tz;
    gchar *tzid_copy;
    g_return_if_fail(I_CAL_VCARD_IS_TZ((ICalVcardTz *)self));
    g_return_if_fail(tzid != NULL);
    tz = ((vcardtztype *)i_cal_object_get_native((ICalObject *)self));
    tzid_copy = g_strdup(tzid);
    tz->tzid = tzid_copy;
    tz->uri = NULL;
    tz->utcoffset = 0;
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_TZID, tzid_copy, g_free);
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_URI, NULL, NULL);
}

/**
 * i_cal_vcard_tz_get_uri:
 * @self: an #ICalVcardTz
 *
 * Gets the URI value of the @self. It can return %NULL when not set or when the @self is not of type URI.
 *
 * Returns: (nullable): a URI
 *
 * Since: 4.0
 *
 **/
const gchar *
i_cal_vcard_tz_get_uri (const ICalVcardTz *self)
{
    g_return_val_if_fail(I_CAL_VCARD_IS_TZ((ICalVcardTz *)self), NULL);
    return ((vcardtztype *)i_cal_object_get_native((ICalObject *)self))->uri;
}

/**
 * i_cal_vcard_tz_set_uri:
 * @self: an #ICalVcardTz
 * @uri: a URI
 *
 * Sets the URI value of the @self.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_tz_set_uri (ICalVcardTz *self, 
                        const gchar *uri)
{
    vcardtztype *tz;
    gchar *uri_copy;
    g_return_if_fail(I_CAL_VCARD_IS_TZ(self));
    g_return_if_fail(uri != NULL);
    tz = ((vcardtztype *)i_cal_object_get_native((ICalObject *)self));
    uri_copy = g_strdup(uri);
    tz->tzid = NULL;
    tz->uri = uri_copy;
    tz->utcoffset = 0;
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_TZID, NULL, NULL);
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_URI, uri_copy, g_free);
}

/**
 * i_cal_vcard_tz_get_utc_offset:
 * @self: an #ICalVcardTz
 *
 * Gets the UTC offset value of the @self. It can return 0 when not set or when the @self is not of UTC
 * offset type.
 *
 * Returns: a UTC offset
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_tz_get_utc_offset (const ICalVcardTz *self)
{
    g_return_val_if_fail(I_CAL_VCARD_IS_TZ((ICalVcardTz *)self), 0);
    return ((vcardtztype *)i_cal_object_get_native((ICalObject *)self))->utcoffset;
}

/**
 * i_cal_vcard_tz_set_utc_offset:
 * @self: an #ICalVcardTz
 * @utc_offset: a UTC offset
 *
 * Sets the UTC offset value of the @self.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_tz_set_utc_offset (ICalVcardTz *self, 
                               gint utc_offset)
{
    vcardtztype *tz;
    g_return_if_fail(I_CAL_VCARD_IS_TZ(self));
    tz = ((vcardtztype *)i_cal_object_get_native((ICalObject *)self));
    tz->tzid = NULL;
    tz->uri = NULL;
    tz->utcoffset = utc_offset;
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_TZID, NULL, NULL);
    g_object_set_data_full(G_OBJECT(self), TZ_KEY_URI, NULL, NULL);
}
