|
1 /* |
|
2 * Copyright (c) 2004 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: Presence reactive authorization transactions. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngReactAuthTransactionImp.h" |
|
20 #include "CPEngAsyncOperation.h" |
|
21 #include "CPEngNWSessionSlotID2.h" |
|
22 #include "CPEngNWSessionSlotStorageProxy.h" |
|
23 #include "CPEngReactAuthPublishOp.h" |
|
24 |
|
25 |
|
26 |
|
27 //LOCAL constants |
|
28 #ifdef _DEBUG |
|
29 namespace |
|
30 { |
|
31 //Panic |
|
32 _LIT( KPEngReactAuthTransPanic, "PEngRctAuthTrn" ); |
|
33 |
|
34 //Panic reasons |
|
35 enum TPEngReactAuthTransPanicReasons |
|
36 { |
|
37 EReactAuthUnkownTransOp |
|
38 }; |
|
39 |
|
40 void PEngReactAuthTransPanic( TPEngReactAuthTransPanicReasons aPanicReason ) |
|
41 { |
|
42 User::Panic( KPEngReactAuthTransPanic, aPanicReason ); |
|
43 } |
|
44 |
|
45 } |
|
46 #endif |
|
47 |
|
48 |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CPEngReactAuthTransactionImp::NewL() |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CPEngReactAuthTransactionImp* CPEngReactAuthTransactionImp::NewL( |
|
59 CPEngReactAuthTransaction& aInterface, |
|
60 TInt aPriority, |
|
61 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
62 { |
|
63 CPEngReactAuthTransactionImp* self = |
|
64 new ( ELeave ) CPEngReactAuthTransactionImp( aInterface, aPriority ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( aNWSessionSlotID ); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 // Destructor |
|
74 CPEngReactAuthTransactionImp::~CPEngReactAuthTransactionImp() |
|
75 { |
|
76 //Cancel also deletes the operation objects |
|
77 CancelPublishReactAuthResponds(); |
|
78 iTransactionServer.Close(); |
|
79 delete iUsedSlot; |
|
80 } |
|
81 |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPEngReactAuthTransactionImp::CPEngReactAuthTransactionImp |
|
86 // C++ default constructor can NOT contain any code, that |
|
87 // might leave. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CPEngReactAuthTransactionImp::CPEngReactAuthTransactionImp( |
|
91 CPEngReactAuthTransaction& aInterface, |
|
92 TInt aPriority ) |
|
93 : iInterface( aInterface ), |
|
94 iCActivePriority( aPriority ) |
|
95 { |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPEngReactAuthTransactionImp::ConstructL() |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CPEngReactAuthTransactionImp::ConstructL( |
|
104 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
105 { |
|
106 iUsedSlot = CPEngNWSessionSlotStorageProxy::NewL( aNWSessionSlotID ); |
|
107 User::LeaveIfError( iTransactionServer.Connect() ); |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CPEngReactAuthTransactionImp::IsPublishReactAuthRespondsActive() |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TBool CPEngReactAuthTransactionImp::IsPublishReactAuthRespondsActive() const |
|
116 { |
|
117 return ( iReactAuthRespondOp != NULL ); // CSI: 64 # |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPEngReactAuthTransactionImp::PublishReactAuthResponds() |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CPEngReactAuthTransactionImp::PublishReactAuthResponds( |
|
126 MPEngAuthorizationRespond*& aResponds, |
|
127 MPEngReactAuthTransactionObserver& aObserver ) |
|
128 { |
|
129 if ( iReactAuthRespondOp ) |
|
130 { |
|
131 return KErrInUse; |
|
132 } |
|
133 |
|
134 CPEngReactAuthPublishOp* op = NULL; |
|
135 TRAPD( err, |
|
136 op = CPEngReactAuthPublishOp::NewL( iCActivePriority, |
|
137 iInterface, |
|
138 *iUsedSlot, |
|
139 aObserver, |
|
140 iTransactionServer, |
|
141 aResponds ); |
|
142 ); |
|
143 |
|
144 if ( err == KErrNone ) |
|
145 { |
|
146 //Success |
|
147 //Operation takes the ownership of aResponds |
|
148 aResponds = NULL; |
|
149 op->PublishResponds(); |
|
150 op->SetOwner( *this ); |
|
151 iReactAuthRespondOp = op; |
|
152 } |
|
153 |
|
154 return err; |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CPEngReactAuthTransactionImp::CancelPublishReactAuthResponds() |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CPEngReactAuthTransactionImp::CancelPublishReactAuthResponds() |
|
163 { |
|
164 if ( iReactAuthRespondOp ) |
|
165 { |
|
166 iReactAuthRespondOp->CancelOpD(); |
|
167 iReactAuthRespondOp = NULL; |
|
168 } |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CPEngReactAuthTransactionImp::HandleAsyncOperationDestruction() |
|
174 // from MPEngAsyncOperationOwner |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CPEngReactAuthTransactionImp::HandleAsyncOperationDestruction( |
|
178 CPEngAsyncOperation* aOperation ) |
|
179 { |
|
180 if ( aOperation == iReactAuthRespondOp ) |
|
181 { |
|
182 iReactAuthRespondOp = NULL; |
|
183 return; |
|
184 } |
|
185 |
|
186 __ASSERT_DEBUG( EFalse, PEngReactAuthTransPanic( EReactAuthUnkownTransOp ) ); |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 // End of File |
|
192 |
|
193 |