|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * CMceCancelSendingOperation. |
|
16 * Cancels first sending of the message and then tries to delete or move it to drafts. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <MTMStore.h> // CMtmStore |
|
25 #include <msvids.h> |
|
26 #include "MceCancelSendingOperation.h" |
|
27 #include "MceLogText.h" |
|
28 |
|
29 // MODULE DATA STRUCTURES |
|
30 |
|
31 // Two-phased constructor. |
|
32 CMceCancelSendingOperation* CMceCancelSendingOperation::NewL( |
|
33 CMsvSession& aMsvSession, |
|
34 TRequestStatus& aObserverRequestStatus, |
|
35 TMsvId aEntryId, |
|
36 TCancelSendingType aCancelType, |
|
37 CMtmStore& aMtmStore ) |
|
38 { |
|
39 MCELOGGER_ENTERFN("CMceCancelSendingOperation::NewL"); |
|
40 CMceCancelSendingOperation* self = new ( ELeave ) CMceCancelSendingOperation( |
|
41 aMsvSession, aObserverRequestStatus, aEntryId, aCancelType, aMtmStore ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::NewL"); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // C++ default constructor can NOT contain any code that |
|
50 // might leave. |
|
51 // |
|
52 CMceCancelSendingOperation::CMceCancelSendingOperation( |
|
53 CMsvSession& aMsvSession, |
|
54 TRequestStatus& aObserverRequestStatus, |
|
55 TMsvId aEntryId, |
|
56 TCancelSendingType aCancelType, |
|
57 CMtmStore& aMtmStore ) |
|
58 : |
|
59 CMsvOperation( |
|
60 aMsvSession, |
|
61 CActive::EPriorityStandard, |
|
62 aObserverRequestStatus), |
|
63 iMtmStore( aMtmStore ), |
|
64 iCancelType( aCancelType ), |
|
65 iEntryId( aEntryId ), |
|
66 iBlank(_L8("")) |
|
67 { |
|
68 CActiveScheduler::Add( this ); |
|
69 } |
|
70 |
|
71 // Symbian OS default constructor can leave. |
|
72 void CMceCancelSendingOperation::ConstructL() |
|
73 { |
|
74 MCELOGGER_ENTERFN("CMceCancelSendingOperation::ConstructL"); |
|
75 iEntry = CMsvEntry::NewL( iMsvSession, iEntryId, TMsvSelectionOrdering() ); |
|
76 iEntrySelection = new( ELeave ) CMsvEntrySelection; |
|
77 iEntrySelection->AppendL( iEntryId ); |
|
78 CancelSendingL(); |
|
79 iCancelState = ECancelling; |
|
80 iStatus = KRequestPending; |
|
81 SetActive(); |
|
82 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::ConstructL"); |
|
83 } |
|
84 |
|
85 |
|
86 //destructor |
|
87 CMceCancelSendingOperation::~CMceCancelSendingOperation() |
|
88 { |
|
89 MCELOGGER_ENTERFN("CMceCancelSendingOperation::~"); |
|
90 Cancel(); |
|
91 delete iOperation; |
|
92 delete iEntry; |
|
93 delete iEntrySelection; |
|
94 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::~"); |
|
95 } |
|
96 |
|
97 |
|
98 |
|
99 // ---------------------------------------------------- |
|
100 // CMceCancelSendingOperation::CancelSendingL |
|
101 // ---------------------------------------------------- |
|
102 void CMceCancelSendingOperation::CancelSendingL() |
|
103 { |
|
104 MCELOGGER_ENTERFN("CMceCancelSendingOperation::CancelSendingL"); |
|
105 CBaseMtmUi& ui = iMtmStore.GetMtmUiLC( iEntry->Entry().iMtm ); |
|
106 iMtm = iEntry->Entry().iMtm; |
|
107 MCELOGGER_WRITE_FORMAT("Start cancelling message id 0x%x", iEntryId ); |
|
108 iOperation = ui.CancelL( iStatus, *iEntrySelection); |
|
109 CleanupStack::PopAndDestroy( );//release mtmUi |
|
110 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::CancelSendingL"); |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------- |
|
114 // CMceCancelSendingOperation::MoveOrDeleteEntryL |
|
115 // ---------------------------------------------------- |
|
116 void CMceCancelSendingOperation::MoveOrDeleteEntryL() |
|
117 { |
|
118 MCELOGGER_ENTERFN("CMceCancelSendingOperation::MoveOrDeleteEntryL"); |
|
119 delete iOperation; |
|
120 iOperation = NULL; |
|
121 iEntry->SetEntryL( KMsvGlobalOutBoxIndexEntryId ); |
|
122 if ( iCancelType == ECancelAndMoveToDrafts ) |
|
123 { |
|
124 MCELOGGER_WRITE_FORMAT("Start moving message id 0x%x to drafts", iEntryId ); |
|
125 iOperation = iEntry->MoveL( |
|
126 *iEntrySelection, KMsvDraftEntryId, iStatus ); |
|
127 } |
|
128 else |
|
129 { |
|
130 MCELOGGER_WRITE_FORMAT("Start deleting message id 0x%x", iEntryId ); |
|
131 iOperation = iEntry->DeleteL( |
|
132 *iEntrySelection, iStatus ); |
|
133 } |
|
134 iMtm = iOperation->Mtm(); |
|
135 |
|
136 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::MoveOrDeleteEntryL"); |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------- |
|
140 // CMceCancelSendingOperation::DoCancel |
|
141 // ---------------------------------------------------- |
|
142 void CMceCancelSendingOperation::DoCancel() |
|
143 { |
|
144 MCELOGGER_ENTERFN("CMceCancelSendingOperation::DoCancel"); |
|
145 if ( iOperation ) |
|
146 { |
|
147 iOperation->Cancel(); |
|
148 } |
|
149 TRequestStatus* status = &iObserverRequestStatus; |
|
150 User::RequestComplete(status, iStatus.Int()); |
|
151 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::DoCancel"); |
|
152 } |
|
153 |
|
154 // ---------------------------------------------------- |
|
155 // CMceCancelSendingOperation::RunL |
|
156 // ---------------------------------------------------- |
|
157 void CMceCancelSendingOperation::RunL() |
|
158 { |
|
159 MCELOGGER_ENTERFN("CMceCancelSendingOperation::RunL"); |
|
160 TInt error = iStatus.Int(); |
|
161 MCELOGGER_WRITE_FORMAT("error: %d", error ); |
|
162 if ( error == KErrNone && iCancelType != ECancelOnly && iCancelState == ECancelling ) |
|
163 { |
|
164 MoveOrDeleteEntryL(); |
|
165 iCancelState = EDeletingOrMoving; |
|
166 iStatus = KRequestPending; |
|
167 SetActive(); |
|
168 } |
|
169 else |
|
170 { |
|
171 // everything is done |
|
172 MCELOGGER_WRITE("everything done, complete" ); |
|
173 TRequestStatus* status = &iObserverRequestStatus; |
|
174 User::RequestComplete(status, iStatus.Int()); |
|
175 } |
|
176 MCELOGGER_LEAVEFN("CMceCancelSendingOperation::RunL"); |
|
177 } |
|
178 // ---------------------------------------------------- |
|
179 // CMceCancelSendingOperation::ProgressL |
|
180 // ---------------------------------------------------- |
|
181 const TDesC8& CMceCancelSendingOperation::ProgressL() |
|
182 { |
|
183 if ( iOperation ) |
|
184 { |
|
185 return iOperation->ProgressL(); |
|
186 } |
|
187 return iBlank; |
|
188 } |
|
189 |
|
190 // End of File |