|
1 // Copyright (c) 2006-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 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include "ss_commsdataobject.h" |
|
22 |
|
23 #include <comms-infras/ss_log.h> |
|
24 |
|
25 #include <comms-infras/api_ext_list.h> |
|
26 #include <es_sock.h> |
|
27 #include <comms-infras/es_parameterbundle.h> |
|
28 #include <comms-infras/es_commsdataobject.h> |
|
29 |
|
30 using namespace ESock; |
|
31 using namespace Messages; |
|
32 |
|
33 TBool TGetOrSetParameters::CanProcess(MeshMachine::TNodeContextBase& aContext) |
|
34 { |
|
35 TUint interfaceId = (*iDataObject)->RequiredItfExtId(); |
|
36 return HasInterface(aContext, (TSupportedCommsApiExt)interfaceId); |
|
37 } |
|
38 |
|
39 void TGetOrSetParameters::ForwardL(MeshMachine::TNodeContextBase& aContext) |
|
40 { |
|
41 TUint interfaceId = (*iDataObject)->RequiredItfExtId(); |
|
42 RLegacyResponseMsg responseMsg(aContext, iMessage, iMessage.Int0()); |
|
43 TRAPD(err, ForwardRequestL(aContext)); |
|
44 if(err == KErrNotFound) |
|
45 { |
|
46 // We've reached the bottom of the stack, so complete the message |
|
47 if ((*iDataObject)->IsProgressive()) |
|
48 { |
|
49 // If the data object was progressive (meaning it traverses the entire |
|
50 // stack progressively building up information using all nodes that |
|
51 // support its required interface) then we complete with KErrNone at |
|
52 // the bottom... |
|
53 __CFLOG_VAR((KESockComponentTag, KESockMessage, |
|
54 _L8("TGetOrSetParameters::ForwardL() Node %08x implementing interface id 0x%08x completing message (%08X) with %d"), |
|
55 &aContext.Node(), interfaceId, iMessage.Handle(), err)); |
|
56 responseMsg.Complete(KErrNone); |
|
57 } |
|
58 else |
|
59 { |
|
60 // ...if on the other hand the data object was not progressive |
|
61 // hitting the bottom of the stack means it didn't find any |
|
62 // nodes that supporting its required interface. In thay case |
|
63 // we complete with KErrNotFound |
|
64 User::Leave(KErrNotFound); |
|
65 } |
|
66 return; |
|
67 } |
|
68 User::LeaveIfError(err); |
|
69 } |
|
70 |
|
71 void TGetOrSetParameters::ProcessL(MeshMachine::TNodeContextBase& aContext) |
|
72 { |
|
73 TAny* interface = NULL; |
|
74 TUint interfaceId = (*iDataObject)->RequiredItfExtId(); |
|
75 TRAPD(err, interface = FetchInterfaceL(aContext.Node(), (TSupportedCommsApiExt)interfaceId)); |
|
76 ASSERT(interface); |
|
77 |
|
78 RLegacyResponseMsg responseMsg(aContext, iMessage, iMessage.Int0()); |
|
79 User::LeaveIfError(err); |
|
80 |
|
81 if (interface) |
|
82 { |
|
83 XCommsDataObject::TProgressAction action(XCommsDataObject::EComplete); |
|
84 TRAP(err, action = (*iDataObject)->DispatchL(interface, this)); |
|
85 if (err != KErrNone) |
|
86 { |
|
87 NM_LOG_START_BLOCK(KESockMessage, _L8("TGetOrSetParameters::ProcessL()")); |
|
88 NM_LOG((KESockMessage, _L8("Node implementing interface id 0x%08x failed with %d"), interfaceId, err)); |
|
89 NM_LOG_NODE(KESockMessage, aContext.Node().Id().Node()); |
|
90 NM_LOG_END_BLOCK(KESockMessage, _L8("TGetOrSetParameters::ProcessL()")); |
|
91 |
|
92 Complete(aContext, err); |
|
93 return; |
|
94 } |
|
95 |
|
96 if ((action == XCommsDataObject::EComplete) |
|
97 || !(*iDataObject)->IsProgressive()) |
|
98 { |
|
99 Complete(aContext, KErrNone); |
|
100 return; |
|
101 } |
|
102 |
|
103 // On successful handling of a progressive data object |
|
104 // forward the data object down to the next node |
|
105 TRAP(err, ForwardRequestL(aContext)); |
|
106 |
|
107 if(err == KErrNotFound) |
|
108 { |
|
109 // We've reached the bottom of the stack, so complete the message |
|
110 Complete(aContext, KErrNone); |
|
111 return; |
|
112 } |
|
113 User::LeaveIfError(err); |
|
114 } |
|
115 } |
|
116 |
|
117 TInt TGetOrSetParameters::CheckError(MeshMachine::TNodeContextBase& /*aContext*/, TInt aError) |
|
118 { |
|
119 // The query set container is owned by the CConnection that originated |
|
120 // this message - if an error occurs we need to delete it and NULL the |
|
121 // pointer |
|
122 if (aError != KErrNone) |
|
123 { |
|
124 delete (*iDataObject); |
|
125 *iDataObject = NULL; |
|
126 } |
|
127 |
|
128 return aError; |
|
129 } |
|
130 |
|
131 void TGetOrSetParameters::Complete(MeshMachine::TNodeContextBase& aContext, TInt aError) |
|
132 { |
|
133 RLegacyResponseMsg responseMsg(aContext, iMessage, iMessage.Int0()); |
|
134 |
|
135 __CFLOG_VAR((KESockComponentTag, KESockMessage, |
|
136 _L8("TGetOrSetParameters::Complete() completing message (%08X) with %d"), |
|
137 iMessage.Handle(), aError)); |
|
138 |
|
139 if ((*iDataObject)->OperationMode() == XCommsDataObject::EOperationSet) |
|
140 { |
|
141 // Done with the object |
|
142 delete (*iDataObject); |
|
143 *iDataObject = NULL; |
|
144 } |
|
145 |
|
146 responseMsg.Complete(aError); |
|
147 } |
|
148 |
|
149 |