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