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