/** @file MOMMessageEvent.h
 *
 * Copyright (C) Espial Limited 2014 - Company confidential - All rights reserved.
 *
 */

#ifndef MOMMessageEvent_h
#define MOMMessageEvent_h

#if ENABLE(RMAI)

#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/AtomicString.h>

#include "MOMEvent.h"
#include "MOMStringCollection.h"

namespace WebCore {

class MOMContentItem;

class MOMMessageEvent : public MOMEvent {
public:
    enum {
        SYSTEM = 0,
        USER = 1,
    };

    static PassRefPtr<MOMMessageEvent> create()
    {
        return adoptRef(new MOMMessageEvent);
    }
    
    int reason() const { return getIntParam(mom_event_MESSAGE_REASON); }
    int length() const { return mom_event_MESSAGE_DATA_COUNT; }
    MOMStringCollection* text() const { return m_object.get(); }
    MOMMessageEvent* data() const { return const_cast<MOMMessageEvent*>(this); }

    int item(int idx) { return idx < mom_event_MESSAGE_DATA_COUNT ? getIntParam(mom_event_MESSAGE_DATA + idx) : 0; }
    
    MOMMessageEvent(const mom_event_params* params, ScriptExecutionContext* context);

private:
    MOMMessageEvent();
    mutable RefPtr<MOMStringCollection> m_object;
};

} // namespace WebCore

#endif // ENABLE(RMAI)

#endif // MOMMessageEvent_h
