|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <elements/mm_context_internal.h> |
|
17 #include <elements/mm_activities.h> |
|
18 #include <elements/mm_node.h> |
|
19 #include <elements/nm_address_internal.h> |
|
20 |
|
21 |
|
22 #ifdef _DEBUG |
|
23 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
24 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
25 _LIT(KSpecAssert_ElemMeshMachCtxC, "ElemMeshMachCtxC"); |
|
26 #endif |
|
27 |
|
28 using namespace MeshMachine; |
|
29 using namespace Messages; |
|
30 |
|
31 EXPORT_C TNodeContextBase::TNodeContextBase(AMMNodeBase& aNode, TSignatureBase& aMessage, const TRuntimeCtxId& aSender, const TNodeId& aRecipient, CNodeActivityBase* aNodeActivity) |
|
32 : iNodeActivity(aNodeActivity), |
|
33 iMessage(aMessage), |
|
34 iNode(aNode), |
|
35 iReturn(KErrNone), |
|
36 iPeer(NULL), |
|
37 iSender(aSender), |
|
38 iRecipient(aRecipient) |
|
39 { |
|
40 const TNodeCtxId* recipient = address_cast<const TNodeCtxId>(&aRecipient); |
|
41 __ASSERT_DEBUG(iNodeActivity==NULL || recipient==NULL || recipient->IsNull() || iNodeActivity->ActivityId() == recipient->NodeCtx(), User::Panic(KSpecAssert_ElemMeshMachCtxC, 1)); |
|
42 |
|
43 //We only allow TNodeNullContext or the aSender must be valid |
|
44 __ASSERT_DEBUG((aSender.IsNull() && aRecipient.IsNull()) || (!aSender.IsNull() && !aRecipient.IsNull()), User::Panic(KSpecAssert_ElemMeshMachCtxC, 2)); |
|
45 if (!iSender.IsNull()) |
|
46 { |
|
47 if (iSender == aNode.Id()) |
|
48 { |
|
49 iPeer = &aNode.SelfInterface(); |
|
50 } |
|
51 else |
|
52 { |
|
53 iPeer = aNode.FindClient(iSender); |
|
54 } |
|
55 } |
|
56 } |
|
57 |
|
58 EXPORT_C TNodeContextBase::~TNodeContextBase() |
|
59 { |
|
60 iPeer = NULL; |
|
61 } |
|
62 |
|
63 EXPORT_C TUint16 TNodeContextBase::ActivityId() const |
|
64 { |
|
65 return iNodeActivity? iNodeActivity->ActivityId() : KActivityNull; |
|
66 } |
|
67 |
|
68 EXPORT_C const TNodeId& TNodeContextBase::NodeId() const |
|
69 { |
|
70 return iNode.Id(); |
|
71 } |
|
72 |
|
73 EXPORT_C void TNodeContextBase::PostToSender(const TSignalBase& aMessage) const |
|
74 { |
|
75 if (iNodeActivity) |
|
76 { |
|
77 RClientInterface::OpenPostMessageClose(TNodeCtxId(iNodeActivity->ActivityId(), NodeId()), iSender, aMessage); |
|
78 } |
|
79 else |
|
80 { |
|
81 //TODO[PROD] - try to use iPeer (can be used for majority of cases) |
|
82 RClientInterface::OpenPostMessageClose(iRecipient, iSender, aMessage); |
|
83 } |
|
84 } |
|
85 |
|
86 EXPORT_C TBool TNodeContextBase::IsPeer() const |
|
87 { |
|
88 return iPeer && iPeer != &iNode.SelfInterface(); |
|
89 } |
|
90 |
|
91 EXPORT_C TBool TNodeContextBase::IsSelf() const |
|
92 { |
|
93 return iPeer == &iNode.SelfInterface(); |
|
94 } |
|
95 |
|
96 |