|
1 /* |
|
2 * Copyright (c) 2008-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 the License "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: |
|
15 * This file implements the SIF Transport Session |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "siftransportserver.h" |
|
21 #include <scs/ipcstream.h> |
|
22 #include <scs/nullstream.h> |
|
23 #include <usif/sif/sif.h> |
|
24 #include "siftransportcommon.h" |
|
25 #include "usiflog.h" |
|
26 |
|
27 using namespace Usif; |
|
28 |
|
29 CSifTransportSession* CSifTransportSession::NewL(CSifTransportServer &aServer, TransportTaskFactory::GenerateTask aTaskFactory) |
|
30 /** |
|
31 Factory function allocates new instance of CSifTransportSession. |
|
32 |
|
33 @return New, initialized instance of CSifTransportSession |
|
34 which is owned by the caller. |
|
35 */ |
|
36 { |
|
37 CSifTransportSession* self = new (ELeave) CSifTransportSession(aServer, aTaskFactory); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CSifTransportSession::CSifTransportSession(CSifTransportServer &aServer, TransportTaskFactory::GenerateTask aTaskFactory) |
|
45 /** |
|
46 This private constructor prevents direct instantiation. |
|
47 */ |
|
48 : CScsSession(aServer), iTaskFactory(aTaskFactory), iExclusiveOperation(ETrue) |
|
49 { |
|
50 DEBUG_PRINTF3(_L8("0x%x CSifSession(server %x)\n"), this, &aServer); |
|
51 } |
|
52 |
|
53 CSifTransportSession::~CSifTransportSession() |
|
54 /** |
|
55 The base class destructor destroys any remaining subsessions |
|
56 or outstanding requests. |
|
57 */ |
|
58 { |
|
59 DEBUG_PRINTF2(_L8("0x%x ~CSifTransportSession)\n"), this); |
|
60 } |
|
61 |
|
62 TBool CSifTransportSession::DoServiceL(TInt aFunction, const RMessage2& aMessage) |
|
63 /** |
|
64 Implement CScsSession by handling the supplied message. |
|
65 |
|
66 Note the subsession creation command is automatically sent to |
|
67 DoCreateSubsessionL, and not this function. |
|
68 |
|
69 @param aFunction Function identifier without SCS code. |
|
70 @param aMessage Standard server-side handle to message. |
|
71 */ |
|
72 { |
|
73 |
|
74 DEBUG_PRINTF3(_L8("0x%x CSifSession::DoServiceL function %d\n"), this, aFunction); |
|
75 |
|
76 // Check if aFunction falls into the expected range |
|
77 if (aFunction < EGetComponentInfoByFileName || aFunction > EDeactivate) |
|
78 { |
|
79 aMessage.Panic(KSifTransportServerRequestError, KErrNotSupported); |
|
80 return ETrue; |
|
81 } |
|
82 |
|
83 // Check if this is an Install or Uninstall request, if yes read the ExclusiveOperation flag from aMessage |
|
84 if (aFunction == EGetComponentInfoByFileName || aFunction == EGetComponentInfoByFileHandle) |
|
85 { |
|
86 // GetComponentInfo requests are always processed regardless of the state of the SIF server. |
|
87 iExclusiveOperation = EFalse; |
|
88 } |
|
89 else if (aFunction >= EInstallByFileName && aFunction <= EUninstallWithOpaqueData) |
|
90 { |
|
91 // Read the ExclusiveOperation flag from aMessage for a synchronous request |
|
92 if (aFunction == EInstallByFileHandleWithOpaqueDataPreamble) |
|
93 { |
|
94 iExclusiveOperation = aMessage.Int0() != EFalse; |
|
95 return ETrue; |
|
96 } |
|
97 |
|
98 // Read the ExclusiveOperation flag from aMessage for asynchronous requests |
|
99 if (aFunction == EInstallByFileName || |
|
100 aFunction == EInstallByFileNameWithOpaqueData || |
|
101 aFunction == EUninstall || |
|
102 aFunction == EUninstallWithOpaqueData) |
|
103 { |
|
104 iExclusiveOperation = aMessage.Int1() != EFalse; |
|
105 } |
|
106 else if (aFunction == EInstallByFileHandle) |
|
107 { |
|
108 iExclusiveOperation = aMessage.Int2() != EFalse; |
|
109 } |
|
110 } |
|
111 else |
|
112 { |
|
113 // We set iExclusiveOperation to ETrue in the constructor. However, we have to |
|
114 // set it here again because the client may send more requests within the same |
|
115 // session. |
|
116 iExclusiveOperation = ETrue; |
|
117 } |
|
118 |
|
119 // If the ExclusiveOperation flag is set to ETrue and there is another pending request we leave with KErrServerBusy |
|
120 if (iExclusiveOperation && iServer.iAsyncRequests.Count() > 0) |
|
121 { |
|
122 User::Leave(KErrServerBusy); |
|
123 } |
|
124 |
|
125 // Create new request and execute it |
|
126 CSifTransportRequest::CreateAndExecuteL(aFunction, this, iTaskFactory, aMessage); |
|
127 |
|
128 return EFalse; |
|
129 } |