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