# shmessage.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 "shmessage.h"
    00019
    00020 // -----------------------------------------------------------------------------
    00021
    00025 ShMessage::ShMessage()
    00026 {
    00027     mMsgType = mtUnknown;
    00028     mSenderId = 0;
    00029     mReceiverId = 0;
    00030     mRequireAck = false;
    00031 }
    00032 // -----------------------------------------------------------------------------
    00033
    00039 bool ShMessage::setMsgType(QString typeStr)
    00040 {
    00041     mMsgType = (typeStr == "set")   ? mtValue :
    00042                (typeStr == "value") ? mtValue :
    00043                (typeStr == "get")   ? mtGet :
    00044                (typeStr == "setOk") ? mtAck :
    00045                (typeStr == "error") ? mtError :
    00046                (typeStr == "reload") ? mtReload : mtUnknown;
    00047
    00048     return mMsgType != mtUnknown;
    00049 }
    00050 // -----------------------------------------------------------------------------
    00051
    00056 QString ShMessage::msgTypeStr()
    00057 {
    00058     switch (mMsgType)
    00059     {
    00060     case mtValue:  return "value";
    00061     case mtGet:    return "get";
    00062     case mtAck:    return "setOk";
    00063     case mtReload: return "reload";
    00064     case mtError:  return "error";
    00065     default:       return "unknown";
    00066     }
    00067 }
    00068 // -----------------------------------------------------------------------------

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends