messagingapp/msgnotifications/flashmsgnotifier/src/flashmsgnotifier_p.cpp
author hgs
Fri, 06 Aug 2010 23:19:50 +0530
changeset 51 3507212d340e
permissions -rw-r--r--
201031_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
3507212d340e 201031_02
hgs
parents:
diff changeset
     1
/*
3507212d340e 201031_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3507212d340e 201031_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
3507212d340e 201031_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
3507212d340e 201031_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
3507212d340e 201031_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
3507212d340e 201031_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
3507212d340e 201031_02
hgs
parents:
diff changeset
     8
 *
3507212d340e 201031_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
3507212d340e 201031_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
3507212d340e 201031_02
hgs
parents:
diff changeset
    11
 *
3507212d340e 201031_02
hgs
parents:
diff changeset
    12
 * Contributors:
3507212d340e 201031_02
hgs
parents:
diff changeset
    13
 *
3507212d340e 201031_02
hgs
parents:
diff changeset
    14
 * Description:  handler for saving and deleting flash messages
3507212d340e 201031_02
hgs
parents:
diff changeset
    15
 *
3507212d340e 201031_02
hgs
parents:
diff changeset
    16
 */
3507212d340e 201031_02
hgs
parents:
diff changeset
    17
3507212d340e 201031_02
hgs
parents:
diff changeset
    18
#include "flashmsgnotifier_p.h"
3507212d340e 201031_02
hgs
parents:
diff changeset
    19
#include <xqconversions.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    20
#include <msvids.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    21
#include <txtrich.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    22
#include <smuthdr.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    23
#include <debugtraces.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    24
#include <ccsrequesthandler.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    25
#include <tmsvsmsentry.h>
3507212d340e 201031_02
hgs
parents:
diff changeset
    26
3507212d340e 201031_02
hgs
parents:
diff changeset
    27
// ================= MEMBER FUNCTIONS =======================
3507212d340e 201031_02
hgs
parents:
diff changeset
    28
3507212d340e 201031_02
hgs
parents:
diff changeset
    29
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    30
// FlashMsgNotifierPrivate::FlashMsgNotifierPrivate
3507212d340e 201031_02
hgs
parents:
diff changeset
    31
// constructor.
3507212d340e 201031_02
hgs
parents:
diff changeset
    32
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    33
//
3507212d340e 201031_02
hgs
parents:
diff changeset
    34
FlashMsgNotifierPrivate::FlashMsgNotifierPrivate(FlashMsgNotifier* notifier) :
3507212d340e 201031_02
hgs
parents:
diff changeset
    35
    iMsvSession(NULL), iRequestHandler(NULL),iNotifier(notifier)
3507212d340e 201031_02
hgs
parents:
diff changeset
    36
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    37
    InitL();
3507212d340e 201031_02
hgs
parents:
diff changeset
    38
}
3507212d340e 201031_02
hgs
parents:
diff changeset
    39
3507212d340e 201031_02
hgs
parents:
diff changeset
    40
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    41
// FlashMsgNotifierPrivate::~FlashMsgNotifierPrivate
3507212d340e 201031_02
hgs
parents:
diff changeset
    42
// Destructor.
3507212d340e 201031_02
hgs
parents:
diff changeset
    43
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    44
//
3507212d340e 201031_02
hgs
parents:
diff changeset
    45
FlashMsgNotifierPrivate::~FlashMsgNotifierPrivate()
3507212d340e 201031_02
hgs
parents:
diff changeset
    46
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    47
    if (iMsvSession) {
3507212d340e 201031_02
hgs
parents:
diff changeset
    48
        delete iMsvSession;
3507212d340e 201031_02
hgs
parents:
diff changeset
    49
        iMsvSession = NULL;
3507212d340e 201031_02
hgs
parents:
diff changeset
    50
    }
3507212d340e 201031_02
hgs
parents:
diff changeset
    51
    if(iRequestHandler) {
3507212d340e 201031_02
hgs
parents:
diff changeset
    52
        delete iRequestHandler;
3507212d340e 201031_02
hgs
parents:
diff changeset
    53
        iRequestHandler = NULL;
3507212d340e 201031_02
hgs
parents:
diff changeset
    54
    }
3507212d340e 201031_02
hgs
parents:
diff changeset
    55
    iNotifier = NULL;
3507212d340e 201031_02
hgs
parents:
diff changeset
    56
3507212d340e 201031_02
hgs
parents:
diff changeset
    57
}
3507212d340e 201031_02
hgs
parents:
diff changeset
    58
3507212d340e 201031_02
hgs
parents:
diff changeset
    59
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    60
// InitL( )
3507212d340e 201031_02
hgs
parents:
diff changeset
    61
// @see header
3507212d340e 201031_02
hgs
parents:
diff changeset
    62
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    63
void FlashMsgNotifierPrivate::InitL()
3507212d340e 201031_02
hgs
parents:
diff changeset
    64
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    65
    iMsvSession = CMsvSession::OpenSyncL(*this);
3507212d340e 201031_02
hgs
parents:
diff changeset
    66
    iRequestHandler = CCSRequestHandler::NewL();
3507212d340e 201031_02
hgs
parents:
diff changeset
    67
}
3507212d340e 201031_02
hgs
parents:
diff changeset
    68
3507212d340e 201031_02
hgs
parents:
diff changeset
    69
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    70
// FlashMsgNotifierPrivate::HandleSessionEventL()
3507212d340e 201031_02
hgs
parents:
diff changeset
    71
// @see header
3507212d340e 201031_02
hgs
parents:
diff changeset
    72
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    73
//
3507212d340e 201031_02
hgs
parents:
diff changeset
    74
void FlashMsgNotifierPrivate::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/,
3507212d340e 201031_02
hgs
parents:
diff changeset
    75
    TAny* /*aArg2*/, TAny* /*aArg3*/)
3507212d340e 201031_02
hgs
parents:
diff changeset
    76
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    77
3507212d340e 201031_02
hgs
parents:
diff changeset
    78
}
3507212d340e 201031_02
hgs
parents:
diff changeset
    79
3507212d340e 201031_02
hgs
parents:
diff changeset
    80
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    81
// FlashMsgNotifierPrivate::DeleteMessage()
3507212d340e 201031_02
hgs
parents:
diff changeset
    82
// @see header
3507212d340e 201031_02
hgs
parents:
diff changeset
    83
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    84
//
3507212d340e 201031_02
hgs
parents:
diff changeset
    85
void FlashMsgNotifierPrivate::DeleteMessage(TMsvId aMsgId)
3507212d340e 201031_02
hgs
parents:
diff changeset
    86
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    87
    iMsvSession->RemoveEntry(aMsgId);
3507212d340e 201031_02
hgs
parents:
diff changeset
    88
}
3507212d340e 201031_02
hgs
parents:
diff changeset
    89
3507212d340e 201031_02
hgs
parents:
diff changeset
    90
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    91
// FlashMsgNotifierPrivate::SaveMessageL()
3507212d340e 201031_02
hgs
parents:
diff changeset
    92
// @see header
3507212d340e 201031_02
hgs
parents:
diff changeset
    93
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
    94
//
3507212d340e 201031_02
hgs
parents:
diff changeset
    95
void FlashMsgNotifierPrivate::SaveMessageL(TMsvId aMsgId)
3507212d340e 201031_02
hgs
parents:
diff changeset
    96
{
3507212d340e 201031_02
hgs
parents:
diff changeset
    97
    QDEBUG_WRITE_FORMAT("SaveMessageL Begin", aMsgId);
3507212d340e 201031_02
hgs
parents:
diff changeset
    98
    
3507212d340e 201031_02
hgs
parents:
diff changeset
    99
    CMsvEntry* msgEntry = iMsvSession->GetEntryL(aMsgId);
3507212d340e 201031_02
hgs
parents:
diff changeset
   100
    CleanupStack::PushL( msgEntry );
3507212d340e 201031_02
hgs
parents:
diff changeset
   101
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   102
    TMsvEntry entry = msgEntry->Entry();
3507212d340e 201031_02
hgs
parents:
diff changeset
   103
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   104
    // If the entry is readonly we need to make it read...
3507212d340e 201031_02
hgs
parents:
diff changeset
   105
    if(entry.ReadOnly())
3507212d340e 201031_02
hgs
parents:
diff changeset
   106
    {
3507212d340e 201031_02
hgs
parents:
diff changeset
   107
        entry.SetReadOnly(EFalse);
3507212d340e 201031_02
hgs
parents:
diff changeset
   108
        entry.SetUnread(EFalse);
3507212d340e 201031_02
hgs
parents:
diff changeset
   109
		entry.SetNew(EFalse);
3507212d340e 201031_02
hgs
parents:
diff changeset
   110
        msgEntry->ChangeL(entry);                
3507212d340e 201031_02
hgs
parents:
diff changeset
   111
    }
3507212d340e 201031_02
hgs
parents:
diff changeset
   112
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   113
    CPlainText* nullString = CPlainText::NewL();
3507212d340e 201031_02
hgs
parents:
diff changeset
   114
    CleanupStack::PushL( nullString );
3507212d340e 201031_02
hgs
parents:
diff changeset
   115
3507212d340e 201031_02
hgs
parents:
diff changeset
   116
    CSmsHeader* smsheader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *nullString);
3507212d340e 201031_02
hgs
parents:
diff changeset
   117
    CleanupStack::PushL( smsheader );
3507212d340e 201031_02
hgs
parents:
diff changeset
   118
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   119
    CMsvStore* store = msgEntry->EditStoreL();
3507212d340e 201031_02
hgs
parents:
diff changeset
   120
    CleanupStack::PushL( store );
3507212d340e 201031_02
hgs
parents:
diff changeset
   121
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   122
    smsheader->RestoreL(*store);
3507212d340e 201031_02
hgs
parents:
diff changeset
   123
    smsheader->Message().SmsPDU().SetClass(ETrue, TSmsDataCodingScheme::ESmsClass1 );
3507212d340e 201031_02
hgs
parents:
diff changeset
   124
    smsheader->StoreL( *store );
3507212d340e 201031_02
hgs
parents:
diff changeset
   125
    store->Commit();
3507212d340e 201031_02
hgs
parents:
diff changeset
   126
    
3507212d340e 201031_02
hgs
parents:
diff changeset
   127
    TMsvSmsEntry entry1 = msgEntry->Entry();
3507212d340e 201031_02
hgs
parents:
diff changeset
   128
    entry1.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass1 );            
3507212d340e 201031_02
hgs
parents:
diff changeset
   129
    msgEntry->ChangeL(entry1);
3507212d340e 201031_02
hgs
parents:
diff changeset
   130
    CleanupStack::PopAndDestroy(4);
3507212d340e 201031_02
hgs
parents:
diff changeset
   131
    QDEBUG_WRITE_FORMAT("SaveMessageL End", aMsgId);
3507212d340e 201031_02
hgs
parents:
diff changeset
   132
}
3507212d340e 201031_02
hgs
parents:
diff changeset
   133
3507212d340e 201031_02
hgs
parents:
diff changeset
   134
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
   135
// FlashMsgNotifierPrivate::GetConversationIdFromAddressL()
3507212d340e 201031_02
hgs
parents:
diff changeset
   136
// @see header
3507212d340e 201031_02
hgs
parents:
diff changeset
   137
// ---------------------------------------------------------
3507212d340e 201031_02
hgs
parents:
diff changeset
   138
//
3507212d340e 201031_02
hgs
parents:
diff changeset
   139
TInt FlashMsgNotifierPrivate::GetConversationIdFromAddressL(
3507212d340e 201031_02
hgs
parents:
diff changeset
   140
        TDesC& aContactAddress)
3507212d340e 201031_02
hgs
parents:
diff changeset
   141
{
3507212d340e 201031_02
hgs
parents:
diff changeset
   142
    return 
3507212d340e 201031_02
hgs
parents:
diff changeset
   143
    iRequestHandler->GetConversationIdFromAddressL(aContactAddress);
3507212d340e 201031_02
hgs
parents:
diff changeset
   144
}
3507212d340e 201031_02
hgs
parents:
diff changeset
   145
3507212d340e 201031_02
hgs
parents:
diff changeset
   146
// End of file