|
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: this class handles the operation for publishing / synhronizing contact lists. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPEngCntLstPublishSyncOp.h" |
|
21 #include "CPEngNWSessionSlotStorageProxy.h" |
|
22 #include "MPEngAdvTransactionStatus2.h" |
|
23 #include "PEngMessagePacker.h" |
|
24 |
|
25 #include <CPEngContactListTransaction2.h> |
|
26 #include <MPEngContactListTransactionObserver2.h> |
|
27 |
|
28 |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // Two-phased constructor. |
|
33 CPEngCntLstPublishSyncOp* CPEngCntLstPublishSyncOp::NewL( TInt aPriority, |
|
34 CPEngContactListTransaction2& aInterface, |
|
35 CPEngNWSessionSlotStorageProxy& aUsedSlot, |
|
36 const MDesCArray& aContactListNames, |
|
37 TBool aSynchronization, |
|
38 MPEngContactListTransactionObserver2& aObserver, |
|
39 RPEngManagerClient& aServer ) |
|
40 { |
|
41 CPEngCntLstPublishSyncOp* self = new ( ELeave ) CPEngCntLstPublishSyncOp( aPriority, |
|
42 aInterface, |
|
43 aObserver, |
|
44 aServer ); |
|
45 |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL( aUsedSlot, aContactListNames, aSynchronization ); |
|
48 CleanupStack::Pop(); |
|
49 |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // Destructor |
|
55 CPEngCntLstPublishSyncOp::~CPEngCntLstPublishSyncOp() |
|
56 { |
|
57 CActive::Cancel(); |
|
58 } |
|
59 |
|
60 |
|
61 // C++ default constructor can NOT contain any code, that |
|
62 // might leave. |
|
63 // |
|
64 CPEngCntLstPublishSyncOp::CPEngCntLstPublishSyncOp( TInt aPriority, |
|
65 CPEngContactListTransaction2& aInterface, |
|
66 MPEngContactListTransactionObserver2& aObserver, |
|
67 RPEngManagerClient& aServer ) |
|
68 : CPEngAsyncOperation( aPriority, aServer ), |
|
69 iInterface( aInterface ), |
|
70 iObserver( aObserver ) |
|
71 { |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 // EPOC default constructor can leave. |
|
77 void CPEngCntLstPublishSyncOp::ConstructL( CPEngNWSessionSlotStorageProxy& aUsedSlot, |
|
78 const MDesCArray& aContactListNames, |
|
79 TBool aSynchronization ) |
|
80 { |
|
81 BaseConstructL( aUsedSlot ); |
|
82 |
|
83 |
|
84 //Check against duplicates |
|
85 const TInt listNameCount = aContactListNames.MdcaCount(); |
|
86 TInt ii; |
|
87 for ( ii = 0; ii < listNameCount - 1; ii++ ) |
|
88 { |
|
89 for ( TInt jj( ii + 1 ); jj < listNameCount; jj++ ) |
|
90 { |
|
91 if ( aContactListNames.MdcaPoint( ii ) == aContactListNames.MdcaPoint( jj ) ) |
|
92 { |
|
93 User::Leave( KErrAlreadyExists ); |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 |
|
99 |
|
100 //Pack the publish request |
|
101 HBufC16* data = PEngMessagePacker::PackDesArrayL( aContactListNames ); |
|
102 if ( aSynchronization ) |
|
103 { |
|
104 InitTransaction( data, EPEngTransOpCntListSyncList ); |
|
105 } |
|
106 else |
|
107 { |
|
108 InitTransaction( data, EPEngTransOpCntListUpdateList ); |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CPEngCntLstPublishSyncOp::IssuePublishSync() |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CPEngCntLstPublishSyncOp::IssuePublishSync() |
|
118 { |
|
119 IssueTransaction(); |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CPEngCntLstPublishSyncOp::DoHandleOpSuccessL() |
|
125 // ----------------------------------------------------------------------------- |
|
126 void CPEngCntLstPublishSyncOp::DoHandleOpSuccessL( |
|
127 MPEngAdvTransactionStatus2& /*aStatus*/, |
|
128 TInt /*aTransactionOperation*/ ) |
|
129 |
|
130 { |
|
131 } |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CPEngCntLstPublishSyncOp::DoHandleOpFailure() |
|
136 // ----------------------------------------------------------------------------- |
|
137 void CPEngCntLstPublishSyncOp::DoHandleOpFailure( |
|
138 MPEngAdvTransactionStatus2& /*aStatus*/, |
|
139 TInt /*aTransactionOperation*/ ) |
|
140 { |
|
141 } |
|
142 |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CPEngCntLstPublishSyncOp::DoNotifyObserver() |
|
146 // ----------------------------------------------------------------------------- |
|
147 TPEngAsyncOpResult CPEngCntLstPublishSyncOp::DoNotifyObserver( |
|
148 MPEngAdvTransactionStatus2& aStatus, |
|
149 TInt aTransactionOperation ) |
|
150 { |
|
151 TRAPD( err, iObserver.HandleContactListTransactionCompleteL( |
|
152 aStatus, |
|
153 iInterface, |
|
154 aTransactionOperation ) ); |
|
155 if ( err != KErrNone ) |
|
156 { |
|
157 iObserver.HandleContactListTransactionError( err, |
|
158 iInterface, |
|
159 aTransactionOperation ); |
|
160 } |
|
161 |
|
162 return EPEngAsyncOpCompleted; |
|
163 } |
|
164 |
|
165 |
|
166 //End of file |
|
167 |
|
168 |