# shobjecthelper.cpp

Go to the documentation of this file.

    00001 /*
    00002  * SmartHome server: Base of the system
    00003  *
    00004  * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
    00005  *
    00006  * This program is free software; you can redistribute it and/or modify it
    00007  * under the terms of version 2 of the GNU General Public License
    00008  * as published by the Free Software Foundation.
    00009  *
    00010  */
    00011
    00018 #include "shobjecthelper.h"
    00019
    00020 // -----------------------------------------------------------------------------
    00021
    00026 ShObjectHelper::ShObjectHelper(QObject *parent) : QObject(parent)
    00027 {
    00028     mId    = 0;
    00029     mIdApi = false;
    00030 }
    00031 // -----------------------------------------------------------------------------
    00032
    00037 void ShObjectHelper::dispatchMessage(ShMessagePtr message)
    00038 {
    00039     message->setSenderId(mId);
    00040     emit newMessage(message);
    00041 }
    00042 // -----------------------------------------------------------------------------
    00043
    00048 void ShObjectHelper::ackMessage(ShMessagePtr message)
    00049 {
    00050     ShMessagePtr shMsg = ShMessagePtr(new ShMessage);
    00051
    00052     shMsg->setMsgType(ShMessage::mtAck);
    00053     shMsg->setSignal(message->signal());
    00054     shMsg->setValue(message->value());
    00055     shMsg->setPin(message->pin());
    00056
    00057     dispatchMessage(shMsg);
    00058 }
    00059 // -----------------------------------------------------------------------------
    00060
    00066 void ShObjectHelper::errorMessage(ShMessagePtr message, QString reason)
    00067 {
    00068     ShMessagePtr shMsg = ShMessagePtr(new ShMessage);
    00069
    00070     shMsg->setMsgType(ShMessage::mtError);
    00071     shMsg->setSignal(message->signal());
    00072     shMsg->setValue(reason);
    00073     shMsg->setPin(message->pin());
    00074
    00075     dispatchMessage(shMsg);
    00076 }
    00077 // -----------------------------------------------------------------------------
    00078
    00084 void ShObjectHelper::outputUpdated(QString signal, QVariant value)
    00085 {
    00086     ShMessagePtr message = ShMessagePtr(new ShMessage);
    00087
    00088     message->setMsgType(ShMessage::mtValue);
    00089     message->setSignal(signal);
    00090     message->setValue(value);
    00091
    00092     dispatchMessage(message);
    00093 }
    00094 // -----------------------------------------------------------------------------

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends