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

#ifndef MOMException_h
#define MOMException_h

#if ENABLE(RMAI)

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

#include "ExceptionBase.h"

extern "C" {
#include "layers.h"
#include "cdf/mom_core.h"
}

namespace WebCore {

class MOMException : public ExceptionBase {
public:
    static const int MOMExceptionOffset = 2000;
    static const int MOMExceptionMax = 2099;

    enum {
        INVALID = MOMExceptionOffset + 1,
        BUSY = MOMExceptionOffset + 2,
        NOTPRESENT = MOMExceptionOffset + 3,
        DISCFULL = MOMExceptionOffset + 4,
        FAILURE = MOMExceptionOffset + 5,
        NOTAUTHORISED = MOMExceptionOffset + 6,
        RATING = MOMExceptionOffset + 7,
        DIALOG = MOMExceptionOffset + 8,
        START_OF_STREAM = MOMExceptionOffset + 9,
        END_OF_STREAM = MOMExceptionOffset + 10,
        TSB_WRAP = MOMExceptionOffset + 11,
        PIN_WRONG = MOMExceptionOffset + 12,
        PIN_LOCKED = MOMExceptionOffset + 13,
        EXPIRED = MOMExceptionOffset + 14,
        UNKNOWN = MOMExceptionOffset + 15,
        NOMEM = MOMExceptionOffset + 16
    };

    static PassRefPtr<MOMException> create(const ExceptionCodeDescription& description);
    static bool initializeDescription(ExceptionCode, ExceptionCodeDescription*);

    static void setFromMOMError(mom_error err, ExceptionCode& ec);
    static int codeFromMOMError(mom_error err);
    static int codeFromMOMError(int err);

protected:
    MOMException(const ExceptionCodeDescription& description);
};

} // namespace WebCore

#endif // ENABLE(RMAI)

#endif // MOMException_h
