|
1 /* |
|
2 * Copyright (c) 2005 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: Base class for SUPL subsessions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <s32mem.h> |
|
23 #include <centralrepository.h> |
|
24 #include <epos_suplterminal.h> |
|
25 |
|
26 #include "epos_suplterminalipc.h" |
|
27 #include "epos_suplterminalerrors.h" |
|
28 #include "epos_csuplprotocolmanagerbase.h" |
|
29 |
|
30 #include "epos_csuplsessionmanager.h" |
|
31 #include "epos_csuplglobal.h" |
|
32 #include "epos_csuplserverpanic.h" |
|
33 #include "epos_csuplipcsubsession.h" |
|
34 #include "epos_csuplnetinitiatedsession.h" |
|
35 #include "epos_mnetinitiatedobserver.h" |
|
36 |
|
37 |
|
38 // CONSTANTS |
|
39 //#ifdef _DEBUG |
|
40 _LIT(KTraceFileName, "SUPL_GW::epos_csuplnetinitiatedsession.cpp"); |
|
41 //#endif |
|
42 |
|
43 // ==================== LOCAL FUNCTIONS ==================== |
|
44 |
|
45 |
|
46 // ================= MEMBER FUNCTIONS ======================= |
|
47 |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // |
|
51 CSuplNetInitiatedSession::CSuplNetInitiatedSession() |
|
52 { |
|
53 } |
|
54 |
|
55 // EPOC default constructor can leave. |
|
56 void CSuplNetInitiatedSession::ConstructL(CSuplSessionManager& aSessnMgr, CSUPLProtocolManagerBase::TSuplReqType aReqType,CSuplServer* aServer,HBufC8* aClientBuf) |
|
57 { |
|
58 |
|
59 DEBUG_TRACE("CSuplNetInitiatedSession::ConstructL", __LINE__) |
|
60 RSuplTerminalSubSession::TSuplServiceType suplService; |
|
61 TInt majorVersion = KErrNotFound; |
|
62 TInt err = aSessnMgr.GetSUPLMessageVersionL(majorVersion,aClientBuf->Des()); |
|
63 |
|
64 if(majorVersion == 1) |
|
65 suplService = RSuplTerminalSubSession::ESUPL_1_0; |
|
66 else |
|
67 suplService = RSuplTerminalSubSession::ESUPL_2_0; |
|
68 |
|
69 iSuplSession = aSessnMgr.CreateNewSessionL(aReqType, 0, suplService ); |
|
70 iSuplSession->SetSUPLVersion(majorVersion); |
|
71 iSuplSessnReq = CSuplSessionRequest::NewL(aSessnMgr, iSuplSession, aServer); |
|
72 |
|
73 |
|
74 } |
|
75 |
|
76 // Two-phased constructor. |
|
77 CSuplNetInitiatedSession* CSuplNetInitiatedSession::NewLC(CSuplSessionManager& aSessnMgr, CSUPLProtocolManagerBase::TSuplReqType aReqType,CSuplServer* aServer,HBufC8* aClientBuf) |
|
78 { |
|
79 DEBUG_TRACE("CSuplNetInitiatedSession::NewLC", __LINE__) |
|
80 CSuplNetInitiatedSession* self = new (ELeave) CSuplNetInitiatedSession(); |
|
81 CleanupClosePushL(*self); |
|
82 self->ConstructL(aSessnMgr, aReqType,aServer,aClientBuf); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // Destructor |
|
87 CSuplNetInitiatedSession::~CSuplNetInitiatedSession() |
|
88 { |
|
89 DEBUG_TRACE("CSuplNetInitiatedSession::~CSuplIPCSubSession", __LINE__) |
|
90 delete iSuplSessnReq; |
|
91 delete iClientBuf; |
|
92 iClientBuf = NULL; |
|
93 } |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CSuplNetInitiatedSession::RequestComplete |
|
102 // |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CSuplNetInitiatedSession::RequestComplete( |
|
107 const RMessage2& aMessage, |
|
108 TInt aCompleteCode) |
|
109 { |
|
110 DEBUG_TRACE("CSuplNetInitiatedSession::RequestComplete", __LINE__) |
|
111 if (!aMessage.IsNull()) |
|
112 { |
|
113 aMessage.Complete(aCompleteCode); |
|
114 } |
|
115 } |
|
116 // --------------------------------------------------------- |
|
117 // CSuplNetInitiatedSession::GetHandle |
|
118 // |
|
119 // (other items were commented in a header). |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 /*TInt CSuplNetInitiatedSession::GetHandle() |
|
123 { |
|
124 DEBUG_TRACE("CSuplNetInitiatedSession::GetHandle", __LINE__) |
|
125 TInt aId=iHandle; |
|
126 return aId; |
|
127 }*/ |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CSuplNetInitiatedSession::ForwardMessageL |
|
131 // |
|
132 // (other items were commented in a header). |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 |
|
136 void CSuplNetInitiatedSession::ForwardMessageL(const RMessage2& aMessage) |
|
137 { |
|
138 DEBUG_TRACE("CSuplNetInitiatedSession::ForwardMessageL", __LINE__) |
|
139 /* TInt length=clientBuf->Length(); |
|
140 iClientBuf=HBufC8::NewL(length); |
|
141 *iClientBuf=*clientBuf;*/ |
|
142 if (iSuplSession != NULL) |
|
143 { |
|
144 delete iClientBuf; |
|
145 iClientBuf = NULL; |
|
146 |
|
147 iClientBuf = SuplGlobal::CopyClientBuffer8LC(aMessage, 0); |
|
148 CleanupStack::Pop(iClientBuf); |
|
149 RequestComplete(aMessage,KErrNone); |
|
150 iSuplSessnReq->ForwardMessageRequestL(iSuplSession,iHandle,iClientBuf); |
|
151 } |
|
152 else |
|
153 RequestComplete(aMessage,KErrNotReady); |
|
154 |
|
155 } |
|
156 // --------------------------------------------------------- |
|
157 // CSuplNetInitiatedSession::SetHandle |
|
158 // |
|
159 // (other items were commented in a header). |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 /*void CSuplNetInitiatedSession::SetHandle(TInt aHandle) |
|
163 { |
|
164 DEBUG_TRACE("CSuplNetInitiatedSession::SetHandle", __LINE__) |
|
165 iHandle=aHandle; |
|
166 }*/ |
|
167 |
|
168 void CSuplNetInitiatedSession::DestroySession(CSuplSessionManager* aSessionMgr) |
|
169 { |
|
170 if(aSessionMgr) |
|
171 aSessionMgr->DestroySession(iSuplSession); |
|
172 } |
|
173 |
|
174 // End of File |
|
175 |