sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// timer message header file
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef __TIMERMESSAGE__H
|
sl@0
|
20 |
#define __TIMERMESSAGE__H
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <e32des8.h>
|
sl@0
|
23 |
const TInt KTimerMsgMaxLen = 12;
|
sl@0
|
24 |
|
sl@0
|
25 |
//encapsulates the timer request message.
|
sl@0
|
26 |
class TRtTimerMsg
|
sl@0
|
27 |
{
|
sl@0
|
28 |
public:
|
sl@0
|
29 |
TRtTimerMsg(const TInt& aTimerId, const TInt& aAction = 0): iTimerId(aTimerId), iRqstAct(aAction){}
|
sl@0
|
30 |
TRtTimerMsg(){}
|
sl@0
|
31 |
inline TInt Serialize(TDes8& aTo) const;
|
sl@0
|
32 |
inline TInt DeSerialize(const TDes8& aFrom);
|
sl@0
|
33 |
|
sl@0
|
34 |
enum
|
sl@0
|
35 |
{
|
sl@0
|
36 |
EDELETETIMER = 2,
|
sl@0
|
37 |
}TRqstAction;
|
sl@0
|
38 |
|
sl@0
|
39 |
TInt iTimerId; // timer id
|
sl@0
|
40 |
TInt iRqstAct;
|
sl@0
|
41 |
};
|
sl@0
|
42 |
|
sl@0
|
43 |
//serialize the timer request.
|
sl@0
|
44 |
TInt TRtTimerMsg::Serialize(TDes8& aTo) const
|
sl@0
|
45 |
{
|
sl@0
|
46 |
TInt lRet = KErrNone;
|
sl@0
|
47 |
if(aTo.MaxSize() != KTimerMsgMaxLen)
|
sl@0
|
48 |
lRet = KErrArgument;
|
sl@0
|
49 |
else
|
sl@0
|
50 |
{
|
sl@0
|
51 |
TUint8 lBuf[KTimerMsgMaxLen];
|
sl@0
|
52 |
Mem::FillZ(&lBuf[0], KTimerMsgMaxLen);
|
sl@0
|
53 |
|
sl@0
|
54 |
Mem::Copy(&lBuf[0], &iTimerId, sizeof(TInt));
|
sl@0
|
55 |
Mem::Copy(&lBuf[sizeof (TInt)], &iRqstAct, sizeof(TInt));
|
sl@0
|
56 |
|
sl@0
|
57 |
aTo.Zero();
|
sl@0
|
58 |
aTo.Append(lBuf,KTimerMsgMaxLen);
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
return lRet;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
//deserialize the timer request.
|
sl@0
|
65 |
TInt TRtTimerMsg::DeSerialize(const TDes8& aFrom)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
TInt lRet = KErrNone;
|
sl@0
|
68 |
if(aFrom.MaxSize() != KTimerMsgMaxLen)
|
sl@0
|
69 |
lRet = KErrArgument;
|
sl@0
|
70 |
else
|
sl@0
|
71 |
{
|
sl@0
|
72 |
const TUint8* lBuf = aFrom.Ptr();
|
sl@0
|
73 |
Mem::Copy(&iTimerId, &lBuf[0], sizeof(TInt));
|
sl@0
|
74 |
Mem::Copy(&iRqstAct, &lBuf[sizeof (TInt)], sizeof(TInt));
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
return lRet;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
#endif // __TIMERMESSAGE__H
|
sl@0
|
81 |
|