javamanager/javacaptain/inc.linux/signalhandlermessages.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:07:20 +0300
branchRCL_3
changeset 17 0fd27995241b
parent 14 04becd199f91
permissions -rw-r--r--
Revision: v2.1.24 Kit: 201019

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  signalhandlermessages
*
*/

#ifndef SIGNALHANDLERMESSAGES_H
#define SIGNALHANDLERMESSAGES_H

#include "logger.h"
#include "comms.h"
#include "commsmessage.h"

using namespace java::comms;

namespace java
{
namespace captain
{
// Message IDs of all installer extension services
const int SIG_MSG_ID_SIGCHLD    = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 30;    // 130
const int SIG_MSG_ID_SIGALRM    = SIG_MSG_ID_SIGCHLD + 1;                       // 131
const int SIG_MSG_ID_SIGINT     = SIG_MSG_ID_SIGALRM + 1;                       // 132

inline void setSignalChildMessage(CommsMessage& aMessage, const int& aPid, const int& aStatus)
{
    aMessage.setModuleId(PLUGIN_ID_SIGNAL_C);
    aMessage.setMessageId(SIG_MSG_ID_SIGCHLD);
    aMessage << aPid << aStatus;
}
inline void getSignalChildMessage(CommsMessage& aMessage, int& aPid, int& aStatus)
{
    if (aMessage.getMessageId() == SIG_MSG_ID_SIGCHLD)
    {
        aMessage >> aPid >> aStatus;
    }
    else
    {
        ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
              aMessage.getMessageId(), SIG_MSG_ID_SIGCHLD);
    }
}

inline void setSignalAlarmMessage(CommsMessage& aMessage)
{
    aMessage.setModuleId(PLUGIN_ID_SIGNAL_C);
    aMessage.setMessageId(SIG_MSG_ID_SIGALRM);
}
inline void getSignalAlarmMessage(CommsMessage& aMessage)
{
    if (aMessage.getMessageId() != SIG_MSG_ID_SIGALRM)
    {
        ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
              aMessage.getMessageId(), SIG_MSG_ID_SIGCHLD);
    }
}

inline void setSignalInterruptMessage(CommsMessage& aMessage)
{
    aMessage.setModuleId(PLUGIN_ID_SIGNAL_C);
    aMessage.setMessageId(SIG_MSG_ID_SIGINT);
}
inline void getSignalInterruptMessage(CommsMessage& aMessage)
{
    if (aMessage.getMessageId() != SIG_MSG_ID_SIGINT)
    {
        ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
              aMessage.getMessageId(), SIG_MSG_ID_SIGINT);
    }
}

} // namespace captain
} // namespace java

#endif // SIGNALHANDLERMESSAGES_H