/*
 *  This file is part of the WebKit open source project.
 *  This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 */

#include "config.h"
#include "WebKitDOMAudioTrack.h"

#include "CSSImportRule.h"
#include "DOMObjectCache.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "JSMainThreadExecState.h"
#include "WebKitDOMAudioTrackPrivate.h"
#include "WebKitDOMPrivate.h"
#include "gobject/ConvertToUTF8String.h"
#include <wtf/GetPtr.h>
#include <wtf/RefPtr.h>

#define WEBKIT_DOM_AUDIO_TRACK_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_TYPE_DOM_AUDIO_TRACK, WebKitDOMAudioTrackPrivate)

typedef struct _WebKitDOMAudioTrackPrivate {
#if ENABLE(VIDEO_TRACK)
    RefPtr<WebCore::AudioTrack> coreObject;
#endif // ENABLE(VIDEO_TRACK)
} WebKitDOMAudioTrackPrivate;

#if ENABLE(VIDEO_TRACK)

namespace WebKit {

WebKitDOMAudioTrack* kit(WebCore::AudioTrack* obj)
{
    if (!obj)
        return 0;

    if (gpointer ret = DOMObjectCache::get(obj))
        return WEBKIT_DOM_AUDIO_TRACK(ret);

    return wrapAudioTrack(obj);
}

WebCore::AudioTrack* core(WebKitDOMAudioTrack* request)
{
    return request ? static_cast<WebCore::AudioTrack*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
}

WebKitDOMAudioTrack* wrapAudioTrack(WebCore::AudioTrack* coreObject)
{
    ASSERT(coreObject);
    return WEBKIT_DOM_AUDIO_TRACK(g_object_new(WEBKIT_TYPE_DOM_AUDIO_TRACK, "core-object", coreObject, NULL));
}

} // namespace WebKit

#endif // ENABLE(VIDEO_TRACK)

G_DEFINE_TYPE(WebKitDOMAudioTrack, webkit_dom_audio_track, WEBKIT_TYPE_DOM_OBJECT)

enum {
    PROP_0,
    PROP_ID,
    PROP_KIND,
    PROP_LABEL,
    PROP_LANGUAGE,
    PROP_ENABLED,
};

static void webkit_dom_audio_track_finalize(GObject* object)
{
    WebKitDOMAudioTrackPrivate* priv = WEBKIT_DOM_AUDIO_TRACK_GET_PRIVATE(object);
#if ENABLE(VIDEO_TRACK)
    WebKit::DOMObjectCache::forget(priv->coreObject.get());
#endif // ENABLE(VIDEO_TRACK)
    priv->~WebKitDOMAudioTrackPrivate();
    G_OBJECT_CLASS(webkit_dom_audio_track_parent_class)->finalize(object);
}

static void webkit_dom_audio_track_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
{
    WebCore::JSMainThreadNullState state;
#if ENABLE(VIDEO_TRACK)
    WebKitDOMAudioTrack* self = WEBKIT_DOM_AUDIO_TRACK(object);
    WebCore::AudioTrack* coreSelf = WebKit::core(self);
#endif // ENABLE(VIDEO_TRACK)
    switch (propertyId) {
    case PROP_ENABLED: {
#if ENABLE(VIDEO_TRACK)
        coreSelf->setEnabled((g_value_get_boolean(value)));
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
        break;
    }
}

static void webkit_dom_audio_track_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
{
    WebCore::JSMainThreadNullState state;
#if ENABLE(VIDEO_TRACK)
    WebKitDOMAudioTrack* self = WEBKIT_DOM_AUDIO_TRACK(object);
    WebCore::AudioTrack* coreSelf = WebKit::core(self);
#endif // ENABLE(VIDEO_TRACK)
    switch (propertyId) {
    case PROP_ID: {
#if ENABLE(VIDEO_TRACK)
        g_value_take_string(value, convertToUTF8String(coreSelf->id()));
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    case PROP_KIND: {
#if ENABLE(VIDEO_TRACK)
        g_value_take_string(value, convertToUTF8String(coreSelf->kind()));
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    case PROP_LABEL: {
#if ENABLE(VIDEO_TRACK)
        g_value_take_string(value, convertToUTF8String(coreSelf->label()));
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    case PROP_LANGUAGE: {
#if ENABLE(VIDEO_TRACK)
        g_value_take_string(value, convertToUTF8String(coreSelf->language()));
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    case PROP_ENABLED: {
#if ENABLE(VIDEO_TRACK)
        g_value_set_boolean(value, coreSelf->enabled());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
        break;
    }
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
        break;
    }
}

static GObject* webkit_dom_audio_track_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties)
{
    GObject* object = G_OBJECT_CLASS(webkit_dom_audio_track_parent_class)->constructor(type, constructPropertiesCount, constructProperties);
#if ENABLE(VIDEO_TRACK)
    WebKitDOMAudioTrackPrivate* priv = WEBKIT_DOM_AUDIO_TRACK_GET_PRIVATE(object);
    priv->coreObject = static_cast<WebCore::AudioTrack*>(WEBKIT_DOM_OBJECT(object)->coreObject);
    WebKit::DOMObjectCache::put(priv->coreObject.get(), object);
#endif // ENABLE(VIDEO_TRACK)
    return object;
}

static void webkit_dom_audio_track_class_init(WebKitDOMAudioTrackClass* requestClass)
{
    GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
    g_type_class_add_private(gobjectClass, sizeof(WebKitDOMAudioTrackPrivate));
    gobjectClass->constructor = webkit_dom_audio_track_constructor;
    gobjectClass->finalize = webkit_dom_audio_track_finalize;
    gobjectClass->set_property = webkit_dom_audio_track_set_property;
    gobjectClass->get_property = webkit_dom_audio_track_get_property;

    g_object_class_install_property(
        gobjectClass,
        PROP_ID,
        g_param_spec_string(
            "id",
            "AudioTrack:id",
            "read-only gchar* AudioTrack:id",
            "",
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_KIND,
        g_param_spec_string(
            "kind",
            "AudioTrack:kind",
            "read-only gchar* AudioTrack:kind",
            "",
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_LABEL,
        g_param_spec_string(
            "label",
            "AudioTrack:label",
            "read-only gchar* AudioTrack:label",
            "",
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_LANGUAGE,
        g_param_spec_string(
            "language",
            "AudioTrack:language",
            "read-only gchar* AudioTrack:language",
            "",
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_ENABLED,
        g_param_spec_boolean(
            "enabled",
            "AudioTrack:enabled",
            "read-write gboolean AudioTrack:enabled",
            FALSE,
            WEBKIT_PARAM_READWRITE));

}

static void webkit_dom_audio_track_init(WebKitDOMAudioTrack* request)
{
    WebKitDOMAudioTrackPrivate* priv = WEBKIT_DOM_AUDIO_TRACK_GET_PRIVATE(request);
    new (priv) WebKitDOMAudioTrackPrivate();
}

gchar* webkit_dom_audio_track_get_id(WebKitDOMAudioTrack* self)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self), 0);
    WebCore::AudioTrack* item = WebKit::core(self);
    gchar* result = convertToUTF8String(item->id());
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
    return 0;
#endif /* ENABLE(VIDEO_TRACK) */
}

gchar* webkit_dom_audio_track_get_kind(WebKitDOMAudioTrack* self)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self), 0);
    WebCore::AudioTrack* item = WebKit::core(self);
    gchar* result = convertToUTF8String(item->kind());
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
    return 0;
#endif /* ENABLE(VIDEO_TRACK) */
}

gchar* webkit_dom_audio_track_get_label(WebKitDOMAudioTrack* self)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self), 0);
    WebCore::AudioTrack* item = WebKit::core(self);
    gchar* result = convertToUTF8String(item->label());
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
    return 0;
#endif /* ENABLE(VIDEO_TRACK) */
}

gchar* webkit_dom_audio_track_get_language(WebKitDOMAudioTrack* self)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self), 0);
    WebCore::AudioTrack* item = WebKit::core(self);
    gchar* result = convertToUTF8String(item->language());
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
    return 0;
#endif /* ENABLE(VIDEO_TRACK) */
}

gboolean webkit_dom_audio_track_get_enabled(WebKitDOMAudioTrack* self)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self), FALSE);
    WebCore::AudioTrack* item = WebKit::core(self);
    gboolean result = item->enabled();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
    return static_cast<gboolean>(0);
#endif /* ENABLE(VIDEO_TRACK) */
}

void webkit_dom_audio_track_set_enabled(WebKitDOMAudioTrack* self, gboolean value)
{
#if ENABLE(VIDEO_TRACK)
    WebCore::JSMainThreadNullState state;
    g_return_if_fail(WEBKIT_DOM_IS_AUDIO_TRACK(self));
    WebCore::AudioTrack* item = WebKit::core(self);
    item->setEnabled(value);
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Video Track")
#endif /* ENABLE(VIDEO_TRACK) */
}

