|
1 /* |
|
2 * Copyright (c) 2002-2007 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 * Entry for scheduled sending of MMS messages |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <apparc.h> |
|
23 #include <msvrcpt.h> |
|
24 #include "mmsscheduledentry.h" |
|
25 #include "mmsconst.h" |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // LOCAL CONSTANTS AND MACROS |
|
36 |
|
37 // MODULE DATA STRUCTURES |
|
38 |
|
39 // LOCAL FUNCTION PROTOTYPES |
|
40 |
|
41 // ==================== LOCAL FUNCTIONS ==================== |
|
42 |
|
43 // ================= MEMBER FUNCTIONS ======================= |
|
44 |
|
45 CMmsRecipient* CMmsRecipient::NewL() |
|
46 { |
|
47 CMmsRecipient* self = new (ELeave) CMmsRecipient(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CMmsRecipient::~CMmsRecipient() |
|
52 { |
|
53 } |
|
54 |
|
55 CMmsRecipient::CMmsRecipient() |
|
56 { |
|
57 iMaxRetries = -1; // can be overridden later |
|
58 } |
|
59 |
|
60 void CMmsRecipient::InternalizeL(RReadStream& aReadStream) |
|
61 { |
|
62 CMsvRecipient::InternalizeL( aReadStream ); |
|
63 aReadStream >> iMaxRetries; |
|
64 } |
|
65 |
|
66 void CMmsRecipient::ExternalizeL(RWriteStream& aWriteStream) const |
|
67 { |
|
68 CMsvRecipient::ExternalizeL( aWriteStream ); |
|
69 aWriteStream << iMaxRetries; |
|
70 } |
|
71 |
|
72 // C++ default constructor can NOT contain any code, that |
|
73 // might leave. |
|
74 // |
|
75 CMmsScheduledEntry::CMmsScheduledEntry( const TMsvEntry& aEntry ) |
|
76 : CMsvScheduledEntry( aEntry ) |
|
77 { |
|
78 } |
|
79 |
|
80 // Symbian OS default constructor can leave. |
|
81 void CMmsScheduledEntry::ConstructL() |
|
82 { |
|
83 iRecipient = CMmsRecipient::NewL(); |
|
84 } |
|
85 |
|
86 // Two-phased constructor. |
|
87 CMmsScheduledEntry* CMmsScheduledEntry::NewL( const TMsvEntry& aEntry ) |
|
88 { |
|
89 CMmsScheduledEntry* self = new (ELeave) CMmsScheduledEntry( aEntry ); |
|
90 |
|
91 CleanupStack::PushL( self ); |
|
92 self->ConstructL(); |
|
93 CleanupStack::Pop( self ); // self |
|
94 |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // Destructor |
|
100 CMmsScheduledEntry::~CMmsScheduledEntry() |
|
101 { |
|
102 delete iRecipient; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CMmsScheduledEntry::CanSendToAnyRecipients |
|
108 // |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 TBool CMmsScheduledEntry::CanSendToAnyRecipients( |
|
112 const CMsvSendErrorActions& aErrorActions, |
|
113 TMsvSendErrorAction& aAction ) |
|
114 { |
|
115 |
|
116 TBool retVal = EFalse; |
|
117 |
|
118 TMsvSendErrorAction action; |
|
119 |
|
120 if (aErrorActions.GetSendErrorAction(iRecipient->Error(), action) != KErrNone) |
|
121 { |
|
122 action = aErrorActions.Default(); |
|
123 } |
|
124 |
|
125 if ( CheckRecipient( *iRecipient, action ) ) |
|
126 { |
|
127 retVal = ETrue; |
|
128 aAction = action; |
|
129 } |
|
130 |
|
131 return retVal; |
|
132 |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CMmsScheduledEntry::CanSendToAnyRecipients |
|
137 // |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 TBool CMmsScheduledEntry::CanSendToAnyRecipients( |
|
141 const TMsvSendErrorAction& aAction ) |
|
142 { |
|
143 |
|
144 TBool retVal = EFalse; |
|
145 retVal = CheckRecipient( *iRecipient, aAction ); |
|
146 return retVal; |
|
147 |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------- |
|
151 // CMmsScheduledEntry::RecipientsResetRetries |
|
152 // |
|
153 // --------------------------------------------------------- |
|
154 // |
|
155 void CMmsScheduledEntry::RecipientsResetRetries() |
|
156 { |
|
157 |
|
158 if ( iRecipient->Status() != CMsvRecipient::ESentSuccessfully ) |
|
159 { |
|
160 iRecipient->ResetRetries(); |
|
161 } |
|
162 |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CMmsScheduledEntry::RecipientsIncreaseRetries |
|
167 // |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 void CMmsScheduledEntry::RecipientsIncreaseRetries() |
|
171 { |
|
172 |
|
173 if (iRecipient->Status() != CMsvRecipient::ESentSuccessfully) |
|
174 { |
|
175 iRecipient->IncreaseRetries(); |
|
176 } |
|
177 |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // CMmsScheduledEntry::RecipientsSetFailed |
|
182 // |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 void CMmsScheduledEntry::RecipientsSetFailed() |
|
186 { |
|
187 |
|
188 if (iRecipient->Status() != CMsvRecipient::ESentSuccessfully) |
|
189 { |
|
190 iRecipient->SetStatus(CMsvRecipient::EFailedToSend); |
|
191 } |
|
192 |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CMmsScheduledEntry::RecipientsAllSent |
|
197 // |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 TBool CMmsScheduledEntry::RecipientsAllSent() const |
|
201 { |
|
202 |
|
203 return ( iRecipient->Status() == CMsvRecipient::ESentSuccessfully ); |
|
204 |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------- |
|
208 // CMmsScheduledEntry::RecipientsStoreL |
|
209 // |
|
210 // --------------------------------------------------------- |
|
211 // |
|
212 void CMmsScheduledEntry::RecipientsStoreL( |
|
213 CMsvStore& aStore ) const |
|
214 { |
|
215 |
|
216 RMsvWriteStream writeStream; |
|
217 writeStream.AssignLC(aStore, KUidMmsRecipientStream); |
|
218 |
|
219 iRecipient->ExternalizeL( writeStream ); |
|
220 |
|
221 writeStream.CommitL(); |
|
222 CleanupStack::PopAndDestroy( &writeStream ); // close writeStream |
|
223 |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------- |
|
227 // CMmsScheduledEntry::RecipientsRestoreL |
|
228 // |
|
229 // --------------------------------------------------------- |
|
230 // |
|
231 void CMmsScheduledEntry::RecipientsRestoreL( |
|
232 CMsvStore& aStore ) |
|
233 { |
|
234 delete iRecipient; |
|
235 iRecipient = NULL; |
|
236 iRecipient = CMmsRecipient::NewL(); |
|
237 |
|
238 if ( aStore.IsPresentL( KUidMmsRecipientStream ) ) |
|
239 { |
|
240 RMsvReadStream readStream; |
|
241 readStream.OpenLC(aStore, KUidMmsRecipientStream); |
|
242 iRecipient->InternalizeL( readStream ); |
|
243 CleanupStack::PopAndDestroy( &readStream ); // close readStream |
|
244 } |
|
245 |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------- |
|
249 // CMmsScheduledEntry::CheckRecipient |
|
250 // |
|
251 // --------------------------------------------------------- |
|
252 // |
|
253 TBool CMmsScheduledEntry::CheckRecipient( |
|
254 CMsvRecipient& aRecipient, |
|
255 const TMsvSendErrorAction& aAction ) |
|
256 { |
|
257 TBool retVal = EFalse; |
|
258 |
|
259 // If max retry override set, use it |
|
260 TInt16 retries = ((CMmsRecipient&)aRecipient).MaxRetries(); |
|
261 if ( retries < 0 ) |
|
262 { |
|
263 retries = aAction.MaxRetries(); |
|
264 } |
|
265 |
|
266 if (aRecipient.Status() != CMsvRecipient::ESentSuccessfully) |
|
267 { |
|
268 if (aAction.iAction == ESendActionSentAlready) |
|
269 { |
|
270 aRecipient.SetStatus(CMsvRecipient::ESentSuccessfully); |
|
271 } |
|
272 else if (aAction.iAction == ESendActionFail) |
|
273 { |
|
274 aRecipient.SetStatus(CMsvRecipient::EFailedToSend); |
|
275 } |
|
276 else if (aAction.iRetries == ESendRetriesInfinite || aRecipient.Retries() < retries ) |
|
277 { |
|
278 aRecipient.SetStatus(CMsvRecipient::ENotYetSent); |
|
279 retVal = ETrue; |
|
280 } |
|
281 else |
|
282 { |
|
283 aRecipient.SetStatus(CMsvRecipient::EFailedToSend); |
|
284 } |
|
285 } |
|
286 |
|
287 return retVal; |
|
288 |
|
289 } |
|
290 |
|
291 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
292 |
|
293 // End of File |
|
294 |