/*
 * SmartHome server: Plug-in x10
 *
 * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 */

/**
 * @file shx10.h
 * @brief Interfaces the X10 network using a CM12U controller
 * @author Daniel Pisi
 */

#ifndef SHX10_H
#define SHX10_H

#include <QtCore/QCoreApplication>
#include <QtPlugin>
#include <QObject>
#include <QQueue>
#include <QRegExp>
#include "shobjecthelper.h"
#include "x10interface.h"

// -----------------------------------------------------------------------------

/**
 * \class ShX10
 * \brief Interfaces the X10 network using a CM12U controller
 */
class ShX10 : public ShObjectHelper
{
    Q_OBJECT
    Q_INTERFACES(ShObject)

public:
    ShX10(QObject *parent = 0);
    virtual ~ShX10() {};
    virtual bool init(QString param);
    virtual void updatePins(const QList<ShPin> &pins) { Q_UNUSED(pins); };
    virtual void processMessage(ShMessagePtr message);

private slots:
    void emitAck();
    void emitErr(QString reason);

private:
    void processNextMessage();

    X10Interface *mInterface;
    QQueue<ShMessagePtr> mMessageQueue;
};
// -----------------------------------------------------------------------------

#endif // SHX10_H
