|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: DCMO Session implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32svr.h> |
|
19 |
|
20 #include "dcmosession.h" |
|
21 #include "dcmoclientserver.h" |
|
22 #include "dcmodebug.h" |
|
23 |
|
24 |
|
25 // ---------------------------------------------------------------------------------------- |
|
26 // CDCMOSession::CDCMOSession |
|
27 // ---------------------------------------------------------------------------------------- |
|
28 CDCMOSession::CDCMOSession() |
|
29 { |
|
30 RDEBUG("CDCMOSession::CDCMOSession"); |
|
31 } |
|
32 |
|
33 // ---------------------------------------------------------------------------------------- |
|
34 // CDCMOSession::Server |
|
35 // ---------------------------------------------------------------------------------------- |
|
36 CDCMOServer& CDCMOSession::Server() |
|
37 { |
|
38 RDEBUG("CDCMOSession::Server"); |
|
39 return *static_cast<CDCMOServer*>(const_cast<CServer2*>(CSession2::Server())); |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------------------- |
|
43 // CDCMOSession::~CDCMOSession |
|
44 // ---------------------------------------------------------------------------------------- |
|
45 CDCMOSession::~CDCMOSession() |
|
46 { |
|
47 RDEBUG("CDCMOSession::~CDCMOSession"); |
|
48 Server().DropSession(); |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------------------- |
|
52 // CDCMOSession::ServiceL |
|
53 // ---------------------------------------------------------------------------------------- |
|
54 void CDCMOSession::ServiceL(const RMessage2& aMessage) |
|
55 { |
|
56 RDEBUG("CDCMOSession::ServiceL"); |
|
57 TRAPD(err,DispatchMessageL(aMessage)); |
|
58 if(err) |
|
59 RDEBUG_2("CDCMOSession::ServiceL - err %d", err ); |
|
60 aMessage.Complete(err); |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------------------- |
|
64 // CDCMOSession::DispatchMessageL |
|
65 // ---------------------------------------------------------------------------------------- |
|
66 void CDCMOSession::DispatchMessageL(const RMessage2& aMessage) |
|
67 { |
|
68 RDEBUG_2("CDCMOSession::DispatchMessageL; %d", aMessage.Function() ); |
|
69 TInt value; |
|
70 TDCMOStatus statusValue; |
|
71 TDCMONode nodeValue; |
|
72 TPckg<TDCMOStatus> status(statusValue); |
|
73 TPckg<TDCMONode> node(nodeValue); |
|
74 TPckg<TInt> intvalue(value); |
|
75 |
|
76 HBufC* category = HBufC::NewLC(KDCMOMaxStringSize); |
|
77 TPtr categoryptr = category->Des(); |
|
78 aMessage.Read (0, categoryptr); |
|
79 aMessage.Read (1, node); |
|
80 switch(aMessage.Function()) |
|
81 { |
|
82 case EDcmoGetAttrInt: |
|
83 { |
|
84 statusValue = Server().GetIntAttributeL(categoryptr, nodeValue, value); |
|
85 aMessage.Write (2, intvalue); |
|
86 aMessage.Write (3, status); |
|
87 RDEBUG_2("CDCMOSession::DispatchMessageL - EDcmoGetAttrInt status %d", statusValue ); |
|
88 } |
|
89 break; |
|
90 case EDcmoGetAttrStr: |
|
91 { |
|
92 HBufC* buf = HBufC::NewLC(KDCMOMaxStringSize); |
|
93 TPtr bufptr = buf->Des(); |
|
94 statusValue = Server().GetStrAttributeL(categoryptr, nodeValue, bufptr); |
|
95 aMessage.Write (2, bufptr); |
|
96 aMessage.Write (3, status); |
|
97 CleanupStack::PopAndDestroy(); //buf |
|
98 RDEBUG_2("CDCMOSession::DispatchMessageL - EDcmoGetAttrStr status %d", statusValue ); |
|
99 } |
|
100 break; |
|
101 case EDcmoSetAttrInt: |
|
102 { |
|
103 if ( KStarterUid == aMessage.SecureId()) |
|
104 { |
|
105 RDEBUG("CDCMOSession:: DispatchMessageL client is starter"); |
|
106 Server().SetStarter( ETrue ); |
|
107 } |
|
108 else if ( !aMessage.HasCapability( ECapabilityDiskAdmin ) ) |
|
109 { |
|
110 statusValue = EDcmoAccessDenied; |
|
111 aMessage.Write (3, status); |
|
112 CleanupStack::PopAndDestroy(category); //category |
|
113 return; |
|
114 } |
|
115 aMessage.Read (2, intvalue); |
|
116 statusValue = Server().SetIntAttributeL(categoryptr, nodeValue, value); |
|
117 aMessage.Write (3, status); |
|
118 RDEBUG_2("CDCMOSession::DispatchMessageL - EDcmoSetAttrInt status %d", statusValue ); |
|
119 } |
|
120 break; |
|
121 |
|
122 case EDcmoSetAttrStr: |
|
123 { |
|
124 if ( KStarterUid == aMessage.SecureId() ) |
|
125 { |
|
126 RDEBUG("CDCMOSession:: DispatchMessageL client is starter"); |
|
127 Server().SetStarter( ETrue ); |
|
128 } |
|
129 else if ( !aMessage.HasCapability( ECapabilityDiskAdmin ) ) |
|
130 { |
|
131 statusValue = EDcmoAccessDenied; |
|
132 aMessage.Write (3, status); |
|
133 CleanupStack::PopAndDestroy( ); //category |
|
134 return; |
|
135 } |
|
136 HBufC* buf = HBufC::NewLC(KDCMOMaxStringSize); |
|
137 TPtr bufptr = buf->Des(); |
|
138 aMessage.Read (2, bufptr); |
|
139 statusValue = Server().SetStrAttributeL(categoryptr, nodeValue, bufptr); |
|
140 aMessage.Write (3, status); |
|
141 CleanupStack::PopAndDestroy(); // buf |
|
142 RDEBUG_2("CDCMOSession::DispatchMessageL - EDcmoSetAttrStr status %d", statusValue ); |
|
143 } |
|
144 break; |
|
145 case EDcmoSearchAdapter: |
|
146 { |
|
147 HBufC* buf = HBufC::NewLC(KDCMOMaxStringSize); |
|
148 TPtr bufptr = buf->Des(); |
|
149 Server().SearchAdaptersL(categoryptr, bufptr); |
|
150 aMessage.Write (1, bufptr); |
|
151 CleanupStack::PopAndDestroy(); //buf |
|
152 RDEBUG("CDCMOSession::DispatchMessageL - EDcmoSearchAdapter status " ); |
|
153 } |
|
154 break; |
|
155 default : |
|
156 RDEBUG("CDCMOSession::DispatchMessageL- Case Not Found" ); |
|
157 } |
|
158 |
|
159 CleanupStack::PopAndDestroy(); //category |
|
160 RDEBUG("CDCMOSession::DispatchMessageL end" ); |
|
161 } |
|
162 // ---------------------------------------------------------------------------------------- |
|
163 // CDCMOSession::ServiceError |
|
164 // Handle an error from CHelloWorldSession::ServiceL() |
|
165 // ---------------------------------------------------------------------------------------- |
|
166 void CDCMOSession::ServiceError(const RMessage2& aMessage,TInt aError) |
|
167 { |
|
168 RDEBUG_2("CDCMOSession::ServiceError %d", aError); |
|
169 CSession2::ServiceError(aMessage,aError); |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------------------- |
|
173 // End of file |