14 * Description: Reads message information from message store. |
14 * Description: Reads message information from message store. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <msvids.h> |
18 #include <msvids.h> |
|
19 #include <msvstd.h> |
19 #include <mmsconst.h> |
20 #include <mmsconst.h> |
20 #include <SendUiConsts.h> |
21 #include <SendUiConsts.h> |
|
22 #include <mtclreg.h> // for CClientMtmRegistry |
|
23 #include <mmsnotificationclient.h> |
|
24 #include <mmssettings.h> |
|
25 #include <xqconversions.h> // from xqutils |
|
26 #include <mmsconst.h> |
|
27 #include <QDateTime> |
|
28 #include <hbglobal.h> |
21 |
29 |
22 #include "msgstorehandler.h" |
30 #include "msgstorehandler.h" |
23 #include "msgbiouids.h" |
31 #include "msgbiouids.h" |
24 #include "convergedmessage.h" |
32 #include "convergedmessage.h" |
25 |
33 |
|
34 // CONSTANTS |
|
35 _LIT(KUnixEpoch, "19700000:000000.000000"); |
|
36 #define BYTES_TO_KBYTES_FACTOR 1024 |
|
37 |
|
38 // LOCALIZATION |
|
39 // TODO : use dialog localizations |
|
40 #define LOC_MESSAGE_SIZE hbTrId("txt_messaging_list_size") |
|
41 #define LOC_CLASS_ADVERTISEMENT hbTrId("txt_messaging_list_advertisement") |
|
42 #define LOC_CLASS_INFORMATIONAL hbTrId("txt_messaging_list_informational") |
|
43 #define LOC_CLASS_PERSONAL hbTrId("txt_messaging_list_personal") |
|
44 #define LOC_MMS_RETRIEVAL_FAILED hbTrId("txt_messaging_dialog_mms_retrieval_failed") |
|
45 #define LOC_MMS_NOTIF_EXPIRED hbTrId("txt_messaging_list_message_expired") |
|
46 #define LOC_MMS_WAITING hbTrId("txt_wireframe_list_multimedia_message_waiting") |
|
47 #define LOC_MMS_RETRIEVING hbTrId("txt_messaging_list_retrieving_message") |
|
48 #define LOC_MMS_EXPIRY_DATE hbTrId("txt_messaging_list_expiry_date") |
|
49 |
26 //---------------------------------------------------------------------------- |
50 //---------------------------------------------------------------------------- |
27 // MsgStoreHandler::MsgStoreHandler |
51 // MsgStoreHandler::MsgStoreHandler |
28 // @see header |
52 // @see header |
29 //---------------------------------------------------------------------------- |
53 //---------------------------------------------------------------------------- |
30 MsgStoreHandler::MsgStoreHandler(): |
54 MsgStoreHandler::MsgStoreHandler(): |
31 iMsvSession(NULL) |
55 iMsvSession(NULL), iNotificationClient(NULL), iMtmReg(NULL) |
32 { |
56 { |
33 InitL(); |
57 InitL(); |
34 } |
58 } |
35 |
59 |
36 //---------------------------------------------------------------------------- |
60 //---------------------------------------------------------------------------- |
37 // MsgStoreHandler::~MsgStoreHandler |
61 // MsgStoreHandler::~MsgStoreHandler |
38 // @see header |
62 // @see header |
39 //---------------------------------------------------------------------------- |
63 //---------------------------------------------------------------------------- |
40 MsgStoreHandler::~MsgStoreHandler() |
64 MsgStoreHandler::~MsgStoreHandler() |
41 { |
65 { |
|
66 if(iNotificationClient) |
|
67 { |
|
68 delete iNotificationClient; |
|
69 iNotificationClient = NULL; |
|
70 } |
|
71 |
|
72 if(iMtmReg) |
|
73 { |
|
74 delete iMtmReg; |
|
75 iMtmReg = NULL; |
|
76 } |
|
77 |
42 if(iMsvSession) |
78 if(iMsvSession) |
43 { |
79 { |
44 delete iMsvSession; |
80 delete iMsvSession; |
45 iMsvSession = NULL; |
81 iMsvSession = NULL; |
46 } |
82 } |
47 } |
83 } |
|
84 |
|
85 //---------------------------------------------------------------------------- |
|
86 // MsgStoreHandler::HandleSessionEventL |
|
87 // @see header |
|
88 //---------------------------------------------------------------------------- |
|
89 void MsgStoreHandler::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
90 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
91 { |
|
92 // Nothing to do |
|
93 } |
48 |
94 |
49 //---------------------------------------------------------------------------- |
95 //---------------------------------------------------------------------------- |
50 // MsgStoreHandler::InitL |
96 // MsgStoreHandler::InitL |
51 // @see header |
97 // @see header |
52 //---------------------------------------------------------------------------- |
98 //---------------------------------------------------------------------------- |
53 void MsgStoreHandler::InitL( ) |
99 void MsgStoreHandler::InitL() |
54 { |
100 { |
55 iMsvSession = CMsvSession::OpenSyncL(*this); |
101 TInt err = KErrNone; |
56 } |
102 TRAP(err,iMsvSession = CMsvSession::OpenSyncL(*this)); |
57 |
103 if(err != KErrNone) |
58 //---------------------------------------------------------------------------- |
104 { |
59 // MsgStoreHandler::markAsReadAndGetType |
105 iMsvSession = NULL; |
60 // @see header |
106 return; |
61 //---------------------------------------------------------------------------- |
107 } |
62 void MsgStoreHandler::markAsReadAndGetType(int msgId, |
108 |
63 int& msgType, |
109 TRAP(err,iMtmReg = CClientMtmRegistry::NewL(*iMsvSession)); |
64 int& msgSubType) |
110 if(err != KErrNone) |
65 { |
111 { |
66 msgType = ConvergedMessage::None; |
112 iMtmReg = NULL; |
67 |
113 return; |
|
114 } |
|
115 } |
|
116 |
|
117 //---------------------------------------------------------------------------- |
|
118 // MsgStoreHandler::MessageLocation |
|
119 // @see header |
|
120 //---------------------------------------------------------------------------- |
|
121 TMsvId MsgStoreHandler::MessageLocation( TMsvId aMsgId ) const |
|
122 { |
|
123 TMsvId parent = NULL; |
|
124 CMsvEntry* cEntry = NULL; |
|
125 TRAPD(err, cEntry = iMsvSession->GetEntryL(aMsgId)); |
|
126 if(err == KErrNone) |
|
127 { |
|
128 TMsvEntry msvEntry = cEntry->Entry(); |
|
129 parent = msvEntry.Parent(); |
|
130 } |
|
131 delete cEntry; |
|
132 return parent; |
|
133 } |
|
134 |
|
135 //---------------------------------------------------------------------------- |
|
136 // MsgStoreHandler::markAsRead |
|
137 // @see header |
|
138 //---------------------------------------------------------------------------- |
|
139 void MsgStoreHandler::markAsRead(int msgId) |
|
140 { |
68 CMsvEntry* cEntry = NULL; |
141 CMsvEntry* cEntry = NULL; |
69 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
142 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
70 if ( err == KErrNone) |
143 if(err == KErrNone) |
71 { |
144 { |
72 TMsvEntry entry = cEntry->Entry(); |
145 TMsvEntry entry = cEntry->Entry(); |
73 if ( entry.Unread() ) |
146 if ( entry.Unread() ) |
74 { |
147 { |
75 // Mark the entry as read |
148 // Mark the entry as read |
76 entry.SetUnread( EFalse ); |
149 entry.SetUnread( EFalse ); |
77 cEntry->ChangeL( entry ); |
150 cEntry->ChangeL( entry ); |
78 } |
151 } |
79 // extract message type |
152 } |
80 extractMsgType(entry,msgType,msgSubType); |
|
81 } |
|
82 |
|
83 delete cEntry; |
153 delete cEntry; |
84 } |
154 } |
85 |
155 |
86 //---------------------------------------------------------------------------- |
156 //---------------------------------------------------------------------------- |
87 // MsgStoreHandler::HandleSessionEventL |
157 // MsgStoreHandler::getMsgTypeInfo |
88 // @see header |
158 // @see header |
89 //---------------------------------------------------------------------------- |
159 //---------------------------------------------------------------------------- |
90 void MsgStoreHandler::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
160 void MsgStoreHandler::getMsgTypeInfo(int msgId, |
91 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
161 int& msgType, |
92 { |
162 int& msgSubType) |
93 // Nothing to do |
163 { |
94 } |
|
95 |
|
96 //---------------------------------------------------------------------------- |
|
97 // MsgStoreHandler::extractMsgType |
|
98 // @see header |
|
99 //---------------------------------------------------------------------------- |
|
100 void MsgStoreHandler::extractMsgType(const TMsvEntry& entry, |
|
101 int& msgType, |
|
102 int& msgSubType) |
|
103 { |
|
104 msgType = ConvergedMessage::None; |
164 msgType = ConvergedMessage::None; |
105 msgSubType = ConvergedMessage::None; |
165 msgSubType = ConvergedMessage::None; |
106 |
166 |
|
167 CMsvEntry* cEntry = NULL; |
|
168 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
|
169 if(err != KErrNone) |
|
170 { |
|
171 // error in getting the entry, return back |
|
172 delete cEntry; |
|
173 return; |
|
174 } |
|
175 |
|
176 TMsvEntry entry = cEntry->Entry(); |
107 switch(entry.iMtm.iUid) |
177 switch(entry.iMtm.iUid) |
108 { |
178 { |
109 case KSenduiMtmSmsUidValue: |
179 case KSenduiMtmSmsUidValue: |
|
180 { |
110 msgType = ConvergedMessage::Sms; |
181 msgType = ConvergedMessage::Sms; |
111 break; |
182 if (entry.iBioType == KMsgBioUidVCard.iUid) |
|
183 { |
|
184 msgSubType = ConvergedMessage::VCard; |
|
185 } |
|
186 break; |
|
187 } |
112 case KSenduiMtmBtUidValue: |
188 case KSenduiMtmBtUidValue: |
113 msgType = ConvergedMessage::BT; |
189 msgType = ConvergedMessage::BT; |
114 break; |
190 break; |
115 case KSenduiMtmMmsUidValue: |
191 case KSenduiMtmMmsUidValue: |
116 msgType = ConvergedMessage::Mms; |
192 msgType = ConvergedMessage::Mms; |
117 break; |
193 break; |
118 case KSenduiMMSNotificationUidValue: |
194 case KSenduiMMSNotificationUidValue: |
119 msgType = ConvergedMessage::MmsNotification; |
195 msgType = ConvergedMessage::MmsNotification; |
120 break; |
196 break; |
121 case KSenduiMtmBioUidValue: |
197 case KSenduiMtmBioUidValue: |
122 { |
198 { |
123 if (entry.iMtmData1 == KSenduiMtmBtUidValue) |
199 if (entry.iMtmData1 == KSenduiMtmBtUidValue) |
124 { |
200 { |
125 msgType = ConvergedMessage::BT; |
201 msgType = ConvergedMessage::BT; |
126 |
202 if (entry.iBioType == KMsgBioUidVCard.iUid) |
127 if (entry.iBioType == KMsgBioUidVCard.iUid) |
203 { |
128 { |
204 msgSubType = ConvergedMessage::VCard; |
129 msgSubType = ConvergedMessage::VCard; |
205 } |
130 } |
206 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
131 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
207 { |
132 { |
208 msgSubType = ConvergedMessage::VCal; |
133 msgSubType = ConvergedMessage::VCal; |
209 } |
134 } |
210 break; |
135 |
211 } |
136 break; |
212 |
137 } |
213 msgType = ConvergedMessage::BioMsg; |
138 msgType = ConvergedMessage::BioMsg; |
|
139 |
|
140 // based on the biotype uid set message type |
214 // based on the biotype uid set message type |
141 if(entry.iBioType == KMsgBioUidRingingTone.iUid) |
215 if(entry.iBioType == KMsgBioUidRingingTone.iUid) |
142 { |
216 { |
143 msgSubType = ConvergedMessage::RingingTone; |
217 msgSubType = ConvergedMessage::RingingTone; |
144 } |
218 } |
145 else if(entry.iBioType == KMsgBioProvisioningMessage.iUid) |
219 else if(entry.iBioType == KMsgBioProvisioningMessage.iUid) |
146 { |
220 { |
147 msgSubType = ConvergedMessage::Provisioning; |
221 msgSubType = ConvergedMessage::Provisioning; |
148 } |
222 } |
149 else if (entry.iBioType == KMsgBioUidVCard.iUid) |
223 else if (entry.iBioType == KMsgBioUidVCard.iUid) |
150 { |
224 { |
151 msgSubType = ConvergedMessage::VCard; |
225 msgSubType = ConvergedMessage::VCard; |
152 } |
226 } |
153 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
227 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
154 { |
228 { |
155 msgSubType = ConvergedMessage::VCal; |
229 msgSubType = ConvergedMessage::VCal; |
156 } |
230 } |
157 } |
231 break; |
158 break; |
232 } |
159 default: |
233 default: |
160 msgType = ConvergedMessage::None; |
234 msgType = ConvergedMessage::None; |
161 break; |
235 break; |
162 } |
236 } |
163 } |
237 delete cEntry; |
|
238 } |
164 |
239 |
165 //---------------------------------------------------------------------------- |
240 //---------------------------------------------------------------------------- |
166 // MsgStoreHandler::deleteMessage |
241 // MsgStoreHandler::deleteMessage |
167 // @see header |
242 // @see header |
168 //---------------------------------------------------------------------------- |
243 //---------------------------------------------------------------------------- |
169 void MsgStoreHandler::deleteMessage(int msgId) |
244 void MsgStoreHandler::deleteMessage(int msgId) |
170 { |
245 { |
171 iMsvSession->RemoveEntry(msgId); |
246 iMsvSession->RemoveEntry(msgId); |
172 } |
247 } |
173 |
248 |
174 //---------------------------------------------------------------------------- |
249 //---------------------------------------------------------------------------- |
175 // MsgStoreHandler::isDraftMessage |
250 // MsgStoreHandler::isDraftMessage |
176 // @see header |
251 // @see header |
177 //---------------------------------------------------------------------------- |
252 //---------------------------------------------------------------------------- |
178 bool MsgStoreHandler::isDraftMessage(int msgId) |
253 bool MsgStoreHandler::isDraftMessage(int msgId) |
179 { |
254 { |
180 bool draftmsg = false; |
255 return (KMsvDraftEntryIdValue == MessageLocation(msgId)); |
|
256 } |
|
257 |
|
258 //---------------------------------------------------------------------------- |
|
259 // MsgStoreHandler::locked |
|
260 // @see header |
|
261 //---------------------------------------------------------------------------- |
|
262 bool MsgStoreHandler::locked(int msgId) |
|
263 { |
|
264 bool msglocked = false; |
181 CMsvEntry* cEntry = NULL; |
265 CMsvEntry* cEntry = NULL; |
182 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
266 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
183 if ( err == KErrNone) |
267 if(err != KErrNone) |
184 { |
268 { |
185 TMsvEntry msvEntry = cEntry->Entry(); |
269 // error in getting the entry e.g. already deleted message |
186 TMsvId parent = msvEntry.Parent(); |
270 msglocked = true; |
187 if(parent == KMsvDraftEntryIdValue) |
271 } |
188 { |
272 else |
189 draftmsg = true; |
273 { |
190 } |
274 // Outbox messages are locked and hence cann't be viewed. |
191 } |
275 // However, make an exception for failed messages. |
192 |
276 TMsvEntry entry = cEntry->Entry(); |
|
277 if( (KMsvGlobalOutBoxIndexEntryIdValue == entry.Parent()) && |
|
278 (KMsvSendStateFailed != entry.SendingState()) ) |
|
279 { |
|
280 msglocked = true; |
|
281 } |
|
282 } |
193 delete cEntry; |
283 delete cEntry; |
194 return draftmsg; |
284 return msglocked; |
195 } |
285 } |
|
286 |
|
287 //---------------------------------------------------------------------------- |
|
288 // MsgStoreHandler::exists |
|
289 // @see header |
|
290 //---------------------------------------------------------------------------- |
|
291 bool MsgStoreHandler::exists(int msgId) |
|
292 { |
|
293 bool msgexists = true; |
|
294 CMsvEntry* cEntry = NULL; |
|
295 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
|
296 if(err != KErrNone) |
|
297 { |
|
298 // error in getting the entry e.g. already deleted message |
|
299 msgexists = false; |
|
300 } |
|
301 delete cEntry; |
|
302 return msgexists; |
|
303 } |
|
304 |
|
305 //---------------------------------------------------------------------------- |
|
306 // MsgStoreHandler::setNotificationMessageId |
|
307 // @see header |
|
308 //---------------------------------------------------------------------------- |
|
309 int MsgStoreHandler::setNotificationMessageId(int msgId) |
|
310 { |
|
311 TRAPD(err, SetNotificationMessageIdL(msgId)); |
|
312 return err; |
|
313 } |
|
314 |
|
315 //---------------------------------------------------------------------------- |
|
316 // MsgStoreHandler::SetNotificationMessageIdL |
|
317 // @see header |
|
318 //---------------------------------------------------------------------------- |
|
319 void MsgStoreHandler::SetNotificationMessageIdL( TMsvId aMsgId ) |
|
320 { |
|
321 // get MMS Notification client mtm & set the content to current entry |
|
322 if(iNotificationClient) |
|
323 { |
|
324 delete iNotificationClient; |
|
325 iNotificationClient = NULL; |
|
326 } |
|
327 iNotificationClient = static_cast<CMmsNotificationClientMtm*>( |
|
328 iMtmReg->NewMtmL( KUidMsgMMSNotification )); |
|
329 iNotificationClient->SwitchCurrentEntryL(aMsgId); |
|
330 iNotificationClient->LoadMessageL(); |
|
331 } |
|
332 |
|
333 //---------------------------------------------------------------------------- |
|
334 // MsgStoreHandler::MaxReceiveSizeLimitL |
|
335 // @see header |
|
336 //---------------------------------------------------------------------------- |
|
337 TInt MsgStoreHandler::MaxReceiveSizeLimitL() |
|
338 { |
|
339 CMmsSettings* settings = CMmsSettings::NewL(); |
|
340 CleanupStack::PushL( settings ); |
|
341 iNotificationClient->RestoreSettingsL(); |
|
342 settings->CopyL( iNotificationClient->MmsSettings() ); |
|
343 TInt maxSize = static_cast<TInt>(settings->MaximumReceiveSize() ); |
|
344 CleanupStack::PopAndDestroy( settings ); |
|
345 return maxSize; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------- |
|
349 // MsgStoreHandler::MmsNotificationStatus |
|
350 // @see header |
|
351 // --------------------------------------------------------- |
|
352 TCsMmsNotificationMsgState |
|
353 MsgStoreHandler::MmsNotificationStatus( TInt aMsvId ) |
|
354 { |
|
355 TMsvId dummy = 0x0; |
|
356 |
|
357 TMsvEntry entry; |
|
358 iMsvSession->GetEntry(aMsvId, dummy, entry); |
|
359 |
|
360 TCsMmsNotificationMsgState status = EMsgStatusNull; |
|
361 |
|
362 TTime currentTime; |
|
363 currentTime.HomeTime( ); |
|
364 TTime expiryTime = iNotificationClient->ExpiryDate( ); |
|
365 TLocale locale; |
|
366 expiryTime += locale.UniversalTimeOffset(); |
|
367 if (locale.QueryHomeHasDaylightSavingOn()) |
|
368 { |
|
369 TTimeIntervalHours daylightSaving(1); |
|
370 expiryTime += daylightSaving; |
|
371 } |
|
372 |
|
373 // operationMask includes operation type. It is not bitmap but ordinal number. |
|
374 // It does not include operation status and result |
|
375 TInt operationMask = (entry.iMtmData2 & KMmsOperationIdentifier) ; |
|
376 |
|
377 // Note! Ongoing operation resets every bit of operation type, operation status |
|
378 // and result. E.g. If message has been forwarded and then fetching starts, |
|
379 // information about forwarding is lost |
|
380 |
|
381 if( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) |
|
382 { |
|
383 if( operationMask == KMmsOperationFetch |
|
384 && OperationOngoing( entry ) ) |
|
385 { |
|
386 // It's in retrieving state |
|
387 status = EMsgStatusRetrieving; |
|
388 } |
|
389 else if( operationMask == KMmsOperationForward |
|
390 && OperationOngoing( entry ) ) |
|
391 { |
|
392 // It's in forwarding state |
|
393 status = EMsgStatusForwarding; |
|
394 } |
|
395 else if( operationMask == KMmsOperationForward |
|
396 && OperationFinished( entry ) |
|
397 && !( entry.iMtmData2 & KMmsOperationResult ) ) |
|
398 { |
|
399 // It's been forwarded succesfully |
|
400 status = EMsgStatusForwarded; |
|
401 } |
|
402 else if( operationMask == KMmsOperationFetch |
|
403 && OperationFinished( entry ) |
|
404 && ( entry.iMtmData2 & KMmsOperationResult |
|
405 || entry.iError ) ) |
|
406 { |
|
407 // Fetch has been failed |
|
408 status = EMsgStatusFailed; |
|
409 } |
|
410 else if( operationMask == KMmsOperationDelete |
|
411 && OperationFinished( entry ) |
|
412 && !( entry.iMtmData2 & KMmsOperationResult ) ) |
|
413 { |
|
414 // It's been deleted succesfully |
|
415 status = EMsgStatusDeleted; |
|
416 } |
|
417 else if( currentTime > expiryTime ) |
|
418 { |
|
419 status = EMsgStatusExpired; |
|
420 } |
|
421 else |
|
422 { // Normal waiting state |
|
423 status = EMsgStatusReadyForFetching; |
|
424 } |
|
425 } |
|
426 |
|
427 return status; |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------- |
|
431 // MsgStoreHandler::OperationOngoing |
|
432 // @see header |
|
433 // --------------------------------------------------------- |
|
434 TBool MsgStoreHandler::OperationOngoing( |
|
435 const TMsvEntry& aEntry ) const |
|
436 { |
|
437 return ( aEntry.iMtmData2 & KMmsOperationOngoing |
|
438 && !( aEntry.iMtmData2 & KMmsOperationFinished ) ); |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------- |
|
442 // MsgStoreHandler::OperationFinished |
|
443 // @see header |
|
444 // --------------------------------------------------------- |
|
445 TBool MsgStoreHandler::OperationFinished( |
|
446 const TMsvEntry& aEntry ) const |
|
447 { |
|
448 return ( aEntry.iMtmData2 & KMmsOperationFinished |
|
449 && !( aEntry.iMtmData2 & KMmsOperationOngoing ) ); |
|
450 } |
|
451 |
|
452 //--------------------------------------------------------------- |
|
453 // MsgStoreHandler::notificationSubject |
|
454 // @see header |
|
455 //--------------------------------------------------------------- |
|
456 QString MsgStoreHandler::notificationSubject() |
|
457 { |
|
458 QString subject; |
|
459 if(iNotificationClient) |
|
460 { |
|
461 TPtrC sub = iNotificationClient->SubjectL(); |
|
462 subject = XQConversions::s60DescToQString(sub); |
|
463 } |
|
464 return subject; |
|
465 } |
|
466 //--------------------------------------------------------------- |
|
467 // MsgStoreHandler::notificationMsgSize |
|
468 // @see header |
|
469 //--------------------------------------------------------------- |
|
470 QString MsgStoreHandler::notificationMsgSize() |
|
471 { |
|
472 // Null check |
|
473 if(!iNotificationClient) |
|
474 { |
|
475 return LOC_MESSAGE_SIZE.arg(0); |
|
476 } |
|
477 |
|
478 // Size of message. |
|
479 TInt size = iNotificationClient->MessageTransferSize(); |
|
480 |
|
481 // read max receive size limit from settings |
|
482 TInt maxSize = 0; |
|
483 TRAP_IGNORE(maxSize = MaxReceiveSizeLimitL()); |
|
484 |
|
485 // apply max size limit rule |
|
486 if( maxSize > 0 ) |
|
487 { |
|
488 if( size > maxSize ) |
|
489 { |
|
490 size = maxSize; |
|
491 } |
|
492 } |
|
493 |
|
494 TInt fileSize = size / BYTES_TO_KBYTES_FACTOR; |
|
495 if ( size % BYTES_TO_KBYTES_FACTOR ) |
|
496 { |
|
497 fileSize++; |
|
498 } |
|
499 |
|
500 return LOC_MESSAGE_SIZE.arg(fileSize); |
|
501 } |
|
502 |
|
503 //--------------------------------------------------------------- |
|
504 // MsgStoreHandler::notificationClass |
|
505 // @see header |
|
506 //--------------------------------------------------------------- |
|
507 QString MsgStoreHandler::notificationClass() |
|
508 { |
|
509 QString notificationClass; |
|
510 // Null Check |
|
511 if(!iNotificationClient) |
|
512 { |
|
513 return notificationClass; |
|
514 } |
|
515 |
|
516 TInt msgClass = iNotificationClient->MessageClass( ); |
|
517 switch( msgClass ) |
|
518 { |
|
519 case EMmsClassPersonal: |
|
520 { |
|
521 notificationClass = LOC_CLASS_PERSONAL; |
|
522 break; |
|
523 } |
|
524 case EMmsClassAdvertisement: |
|
525 { |
|
526 notificationClass = LOC_CLASS_ADVERTISEMENT; |
|
527 break; |
|
528 } |
|
529 case EMmsClassInformational: |
|
530 { |
|
531 notificationClass = LOC_CLASS_INFORMATIONAL; |
|
532 break; |
|
533 } |
|
534 default: |
|
535 { // In case no class is returned (0), don't add the field |
|
536 break; |
|
537 } |
|
538 } |
|
539 return notificationClass; |
|
540 } |
|
541 |
|
542 //--------------------------------------------------------------- |
|
543 // MsgStoreHandler::notificationStatus |
|
544 // @see header |
|
545 //--------------------------------------------------------------- |
|
546 void MsgStoreHandler::notificationStatus( |
|
547 int& status, |
|
548 QString& statusStr) |
|
549 { |
|
550 // Null Check |
|
551 if(!iNotificationClient) |
|
552 { |
|
553 return; |
|
554 } |
|
555 |
|
556 // fetch mms notification status from store handler |
|
557 // and map as per our UI requirements |
|
558 TMsvEntry entry = iNotificationClient->Entry().Entry(); |
|
559 status = MmsNotificationStatus(entry.Id()); |
|
560 switch(status) |
|
561 { |
|
562 case ConvergedMessage::NotifFailed: |
|
563 { |
|
564 statusStr = LOC_MMS_RETRIEVAL_FAILED; |
|
565 break; |
|
566 } |
|
567 case ConvergedMessage::NotifExpired: |
|
568 { |
|
569 statusStr = LOC_MMS_NOTIF_EXPIRED; |
|
570 break; |
|
571 } |
|
572 case ConvergedMessage::NotifReadyForFetching: |
|
573 { |
|
574 statusStr = LOC_MMS_WAITING; |
|
575 break; |
|
576 } |
|
577 case ConvergedMessage::NotifWaiting: |
|
578 case ConvergedMessage::NotifRetrieving: |
|
579 { |
|
580 statusStr = LOC_MMS_RETRIEVING; |
|
581 break; |
|
582 } |
|
583 default: |
|
584 { |
|
585 // not handled, do nothing |
|
586 break; |
|
587 } |
|
588 } |
|
589 } |
|
590 |
|
591 //--------------------------------------------------------------- |
|
592 // MsgStoreHandler::notificationExpiryDate |
|
593 // @see header |
|
594 //--------------------------------------------------------------- |
|
595 QString MsgStoreHandler::notificationExpiryDate() |
|
596 { |
|
597 // Null Check |
|
598 if(!iNotificationClient) |
|
599 { |
|
600 return QString(); |
|
601 } |
|
602 |
|
603 // get expiry time from entry |
|
604 TTime expiryTime = iNotificationClient->ExpiryDate( ); |
|
605 TLocale locale; |
|
606 expiryTime += locale.UniversalTimeOffset(); |
|
607 if (locale.QueryHomeHasDaylightSavingOn()) |
|
608 { |
|
609 TTimeIntervalHours daylightSaving(1); |
|
610 expiryTime += daylightSaving; |
|
611 } |
|
612 |
|
613 // create formatted string for the expiry time |
|
614 TTime unixEpoch(KUnixEpoch); |
|
615 TTimeIntervalSeconds seconds; |
|
616 expiryTime.SecondsFrom(unixEpoch, seconds); |
|
617 return LOC_MMS_EXPIRY_DATE.arg(seconds.Int()); |
|
618 } |
|
619 |
196 // End of file |
620 // End of file |