messagingapp/msgappfw/plugins/previewplugin/src/ccspreviewpluginhandler.cpp
author hgs
Sun, 25 Jul 2010 18:59:19 +0530
changeset 48 4f501b74aeb1
parent 37 518b245aa84c
child 56 f42d9a78f435
permissions -rw-r--r--
201029_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2007 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:  CS Preview Plugin Handler, This class creates and updates sqlite based db
hgs
parents:
diff changeset
    15
 *                with the message-preview data.
hgs
parents:
diff changeset
    16
 *
hgs
parents:
diff changeset
    17
 */
hgs
parents:
diff changeset
    18
// USER INCLUDES
hgs
parents:
diff changeset
    19
#include "ccspreviewpluginhandler.h"
hgs
parents:
diff changeset
    20
#include "UniObject.h"
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    21
#include "msgbiouids.h"
37
hgs
parents:
diff changeset
    22
// SYSTEM INCLUDES
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    23
#include <bioscmds.h>
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    24
#include <biocmtm.h>
37
hgs
parents:
diff changeset
    25
#include <mmsclient.h>
hgs
parents:
diff changeset
    26
#include <mtclreg.h>
hgs
parents:
diff changeset
    27
#include <msvids.h>
hgs
parents:
diff changeset
    28
#include <e32const.h>
hgs
parents:
diff changeset
    29
#include <SendUiConsts.h>
hgs
parents:
diff changeset
    30
#include <utf.h>
hgs
parents:
diff changeset
    31
#include <centralrepository.h>
hgs
parents:
diff changeset
    32
#include <MmsConformance.h>
hgs
parents:
diff changeset
    33
#include <mmsconst.h>
hgs
parents:
diff changeset
    34
#include <msgmediainfo.h>
hgs
parents:
diff changeset
    35
#include <MsgMediaResolver.h>
hgs
parents:
diff changeset
    36
#include <fileprotectionresolver.h>
hgs
parents:
diff changeset
    37
#include <MmsEngineInternalCRKeys.h>
hgs
parents:
diff changeset
    38
//CONSTANTS
hgs
parents:
diff changeset
    39
//DB-file
hgs
parents:
diff changeset
    40
_LIT(KDbFileName, "c:[2002A542]conversations.db");
hgs
parents:
diff changeset
    41
//Encoding
hgs
parents:
diff changeset
    42
_LIT(KEncodingStmnt,"PRAGMA encoding=\"UTF-8\"");
hgs
parents:
diff changeset
    43
//Size
hgs
parents:
diff changeset
    44
_LIT(KCacheSizeStmnt,"PRAGMA default_cache_size = 1024");
hgs
parents:
diff changeset
    45
// Create table query statement
hgs
parents:
diff changeset
    46
_LIT(KSqlCreateStmt, "CREATE TABLE IF NOT EXISTS conversation_messages ( message_id  INTEGER PRIMARY KEY, msg_processingstate INTEGER DEFAULT 0, subject TEXT(100), body_text TEXT(160), preview_path TEXT, msg_property INTEGER, preview_icon BLOB DEFAULT NULL ) " );
hgs
parents:
diff changeset
    47
//Create an empty record for the given message id
hgs
parents:
diff changeset
    48
_LIT(KSqlBasicInsertStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id ) VALUES( :message_id )");
hgs
parents:
diff changeset
    49
//Insert without bitmap query
hgs
parents:
diff changeset
    50
_LIT(KSqlInsertStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id, msg_processingstate, subject, body_text, preview_path, msg_property ) VALUES( :message_id, :msg_processingstate, :subject, :body_text, :preview_path,  :msg_property )");
hgs
parents:
diff changeset
    51
//update processing-state flag of a message
hgs
parents:
diff changeset
    52
_LIT(KSqlUpdateProcessingStateStmt, "UPDATE conversation_messages SET msg_processingstate=:msg_processingstate WHERE message_id=:message_id " );
hgs
parents:
diff changeset
    53
//update with bitmap query
hgs
parents:
diff changeset
    54
_LIT(KSqlUpdateBitmapStmt, "UPDATE conversation_messages SET preview_icon=:preview_icon WHERE message_id=:message_id " );
hgs
parents:
diff changeset
    55
// query to see if msg is under process at the moment
hgs
parents:
diff changeset
    56
_LIT(KSelectProcessingStateStmt, " SELECT message_id, msg_processingstate FROM conversation_messages WHERE message_id=:message_id ");
hgs
parents:
diff changeset
    57
// Remove record from conversation_messages table.
hgs
parents:
diff changeset
    58
_LIT(KRemoveMsgStmnt,"DELETE FROM conversation_messages WHERE message_id=:message_id");
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    59
//Insert vcard meta-daa query
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
    60
_LIT(KSqlInsertBioMsgStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id, msg_processingstate, preview_path ) VALUES( :message_id, :msg_processingstate, :preview_path )");
37
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
const TInt KDefaultMaxSize = 300 * 1024;
hgs
parents:
diff changeset
    63
//Preview thumbnail size
hgs
parents:
diff changeset
    64
const TInt KWidth = 9.5 * 6.7;
hgs
parents:
diff changeset
    65
const TInt KHeight = 9.5 * 6.7;
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
// NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
// ============================== MEMBER FUNCTIONS ============================
hgs
parents:
diff changeset
    70
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    71
// CCsPreviewPluginHandler::NewL
hgs
parents:
diff changeset
    72
// Two Phase Construction
hgs
parents:
diff changeset
    73
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    74
//
hgs
parents:
diff changeset
    75
CCsPreviewPluginHandler* CCsPreviewPluginHandler::NewL(
hgs
parents:
diff changeset
    76
    CCsPreviewPlugin *aMsgObserver)
hgs
parents:
diff changeset
    77
{
hgs
parents:
diff changeset
    78
    PRINT ( _L("Enter CCsMsgHandler::NewL") );
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
    CCsPreviewPluginHandler* self = new (ELeave) CCsPreviewPluginHandler();
hgs
parents:
diff changeset
    81
    CleanupStack::PushL(self);
hgs
parents:
diff changeset
    82
    self->ConstructL(aMsgObserver);
hgs
parents:
diff changeset
    83
    CleanupStack::Pop(self);
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
    PRINT ( _L("End CCsPreviewPluginHandler::NewL") );
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
    return self;
hgs
parents:
diff changeset
    88
}
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    91
// CCsPreviewPluginHandler::~CCsPreviewPluginHandler
hgs
parents:
diff changeset
    92
// Destructor
hgs
parents:
diff changeset
    93
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    94
//
hgs
parents:
diff changeset
    95
CCsPreviewPluginHandler::~CCsPreviewPluginHandler()
hgs
parents:
diff changeset
    96
{
hgs
parents:
diff changeset
    97
    PRINT ( _L("Enter CCsPreviewPluginHandler::~CCsPreviewPluginHandler") );
hgs
parents:
diff changeset
    98
hgs
parents:
diff changeset
    99
    iSqlDb.Close();
hgs
parents:
diff changeset
   100
    iThumbnailRequestArray.Close();
hgs
parents:
diff changeset
   101
    ifsSession.Close();
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
    if (iMmsMtm)
hgs
parents:
diff changeset
   104
    {
hgs
parents:
diff changeset
   105
        delete iMmsMtm;
hgs
parents:
diff changeset
   106
        iMmsMtm = NULL;
hgs
parents:
diff changeset
   107
    }
hgs
parents:
diff changeset
   108
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   109
    if (iBioClientMtm)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   110
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   111
        delete iBioClientMtm;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   112
        iBioClientMtm = NULL;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   113
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   114
37
hgs
parents:
diff changeset
   115
    if (iMtmRegistry)
hgs
parents:
diff changeset
   116
    {
hgs
parents:
diff changeset
   117
        delete iMtmRegistry;
hgs
parents:
diff changeset
   118
        iMtmRegistry = NULL;
hgs
parents:
diff changeset
   119
    }
hgs
parents:
diff changeset
   120
hgs
parents:
diff changeset
   121
    if (iSession)
hgs
parents:
diff changeset
   122
    {
hgs
parents:
diff changeset
   123
        delete iSession;
hgs
parents:
diff changeset
   124
        iSession = NULL;
hgs
parents:
diff changeset
   125
    }
hgs
parents:
diff changeset
   126
hgs
parents:
diff changeset
   127
    if (iThumbnailManager)
hgs
parents:
diff changeset
   128
    {
hgs
parents:
diff changeset
   129
        delete iThumbnailManager;
hgs
parents:
diff changeset
   130
        iThumbnailManager = NULL;
hgs
parents:
diff changeset
   131
    }
hgs
parents:
diff changeset
   132
hgs
parents:
diff changeset
   133
    PRINT ( _L("End CCsPreviewPluginHandler::~CCsPreviewPluginHandler") );
hgs
parents:
diff changeset
   134
}
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   137
// CCsMsgHandler::ConstructL
hgs
parents:
diff changeset
   138
// Two Phase Construction
hgs
parents:
diff changeset
   139
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   140
//
hgs
parents:
diff changeset
   141
void CCsPreviewPluginHandler::ConstructL(CCsPreviewPlugin *aMsgObserver)
hgs
parents:
diff changeset
   142
{
hgs
parents:
diff changeset
   143
    PRINT ( _L("Enter CCsPreviewPluginHandler::ConstructL") );
hgs
parents:
diff changeset
   144
hgs
parents:
diff changeset
   145
    iMsgObserver = aMsgObserver;
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
    //file session connect
hgs
parents:
diff changeset
   148
    User::LeaveIfError(ifsSession.Connect());
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
    //create msv session
hgs
parents:
diff changeset
   151
    iSession = CMsvSession::OpenSyncL(*this);
hgs
parents:
diff changeset
   152
hgs
parents:
diff changeset
   153
    //create mtm registry
hgs
parents:
diff changeset
   154
    iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
hgs
parents:
diff changeset
   155
hgs
parents:
diff changeset
   156
    //create mms client mtm
hgs
parents:
diff changeset
   157
    iMmsMtm = static_cast<CMmsClientMtm*> (iMtmRegistry-> NewMtmL(
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   158
            KSenduiMtmMmsUid));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   159
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   160
    // create biomsg client mtm
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   161
    iBioClientMtm = static_cast<CBIOClientMtm*> (iMtmRegistry->NewMtmL(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   162
            KSenduiMtmBioUid));
37
hgs
parents:
diff changeset
   163
hgs
parents:
diff changeset
   164
    //create thumbnail manager
hgs
parents:
diff changeset
   165
    iThumbnailManager = CThumbnailManager::NewL(*this);
hgs
parents:
diff changeset
   166
hgs
parents:
diff changeset
   167
    // open DB
hgs
parents:
diff changeset
   168
    TInt error = iSqlDb.Open(KDbFileName);
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
    PRINT1 ( _L("End CCsPreviewPluginHandler::ConstructL open DB file error=%d"), error );
hgs
parents:
diff changeset
   171
hgs
parents:
diff changeset
   172
    // if not found, create DB
hgs
parents:
diff changeset
   173
    if (error == KErrNotFound)
hgs
parents:
diff changeset
   174
    {
hgs
parents:
diff changeset
   175
        //create sqlite-DB
hgs
parents:
diff changeset
   176
        TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass);
hgs
parents:
diff changeset
   177
        RSqlSecurityPolicy securityPolicy;
hgs
parents:
diff changeset
   178
        securityPolicy.Create(defaultPolicy);
hgs
parents:
diff changeset
   179
hgs
parents:
diff changeset
   180
        // TODO, setting UID security policy
hgs
parents:
diff changeset
   181
        //TSecurityPolicy readPolicy(ECapabilityReadUserData);  
hgs
parents:
diff changeset
   182
        //securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, readPolicy);
hgs
parents:
diff changeset
   183
hgs
parents:
diff changeset
   184
        iSqlDb.Create(KDbFileName, securityPolicy);
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
        //Create the table inside DB
hgs
parents:
diff changeset
   187
        iSqlDb.Exec(KSqlCreateStmt);
hgs
parents:
diff changeset
   188
        iSqlDb.Exec(KEncodingStmnt);
hgs
parents:
diff changeset
   189
        iSqlDb.Exec(KCacheSizeStmnt);
hgs
parents:
diff changeset
   190
    }
hgs
parents:
diff changeset
   191
    else
hgs
parents:
diff changeset
   192
    {
hgs
parents:
diff changeset
   193
        User::LeaveIfError(error);
hgs
parents:
diff changeset
   194
    }
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
    //get the max size of mms from the repository
hgs
parents:
diff changeset
   197
    TRAP_IGNORE(
hgs
parents:
diff changeset
   198
            CRepository* repository = CRepository::NewL(KCRUidMmsEngine);
hgs
parents:
diff changeset
   199
            CleanupStack::PushL(repository);
hgs
parents:
diff changeset
   200
hgs
parents:
diff changeset
   201
            //Fetch and set max mms composition size
hgs
parents:
diff changeset
   202
            TInt maxSize = KDefaultMaxSize;
hgs
parents:
diff changeset
   203
            repository->Get( KMmsEngineMaximumSendSize, maxSize );
hgs
parents:
diff changeset
   204
            iMaxMmsSize = maxSize;
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
            //Fetch and set creation mode
hgs
parents:
diff changeset
   207
            TInt creationMode = EMmsCreationModeRestricted;
hgs
parents:
diff changeset
   208
            repository->Get(KMmsEngineCreationMode, creationMode);
hgs
parents:
diff changeset
   209
            iCreationMode = creationMode;
hgs
parents:
diff changeset
   210
hgs
parents:
diff changeset
   211
            CleanupStack::PopAndDestroy(repository);
hgs
parents:
diff changeset
   212
    );
hgs
parents:
diff changeset
   213
    PRINT ( _L("End CCsPreviewPluginHandler::ConstructL") );
hgs
parents:
diff changeset
   214
}
hgs
parents:
diff changeset
   215
hgs
parents:
diff changeset
   216
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   217
// CCsPreviewPluginHandler::CCsPreviewPluginHandler
hgs
parents:
diff changeset
   218
// Two Phase Construction
hgs
parents:
diff changeset
   219
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   220
//
hgs
parents:
diff changeset
   221
CCsPreviewPluginHandler::CCsPreviewPluginHandler()
hgs
parents:
diff changeset
   222
{
hgs
parents:
diff changeset
   223
}
hgs
parents:
diff changeset
   224
hgs
parents:
diff changeset
   225
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   226
// CCsPreviewPluginHandler::HandleSessionEventL
hgs
parents:
diff changeset
   227
// Implemented for MMsvSessionObserver
hgs
parents:
diff changeset
   228
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   229
//
hgs
parents:
diff changeset
   230
void CCsPreviewPluginHandler::HandleSessionEventL(TMsvSessionEvent aEvent,
hgs
parents:
diff changeset
   231
    TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
hgs
parents:
diff changeset
   232
{
hgs
parents:
diff changeset
   233
    PRINT1 ( _L("Enter CCsPreviewPluginHandler::HandleSessionEventL aEvent=%d"),aEvent );
hgs
parents:
diff changeset
   234
hgs
parents:
diff changeset
   235
    CMsvEntrySelection* selection = NULL;
hgs
parents:
diff changeset
   236
    TMsvId parent;
hgs
parents:
diff changeset
   237
hgs
parents:
diff changeset
   238
    //args
hgs
parents:
diff changeset
   239
    if (aArg1 == NULL || aArg2 == NULL)
hgs
parents:
diff changeset
   240
    {
hgs
parents:
diff changeset
   241
        PRINT ( _L("Enter CCsPreviewPluginHandler::HandleSessionEventL arguments invalid"));
hgs
parents:
diff changeset
   242
        return;
hgs
parents:
diff changeset
   243
    }
hgs
parents:
diff changeset
   244
hgs
parents:
diff changeset
   245
    //start, processing the event
hgs
parents:
diff changeset
   246
    selection = (CMsvEntrySelection*) aArg1;
hgs
parents:
diff changeset
   247
    parent = *(TMsvId*) aArg2;
hgs
parents:
diff changeset
   248
hgs
parents:
diff changeset
   249
    //Drafts not handled
hgs
parents:
diff changeset
   250
    if (KMsvDraftEntryIdValue == parent)
hgs
parents:
diff changeset
   251
    {
hgs
parents:
diff changeset
   252
        return;
hgs
parents:
diff changeset
   253
    }
hgs
parents:
diff changeset
   254
hgs
parents:
diff changeset
   255
    switch (aEvent)
hgs
parents:
diff changeset
   256
    {
hgs
parents:
diff changeset
   257
        case EMsvEntriesChanged:
hgs
parents:
diff changeset
   258
        case EMsvEntriesMoved:
hgs
parents:
diff changeset
   259
        {
hgs
parents:
diff changeset
   260
            HandleEventL(selection);
hgs
parents:
diff changeset
   261
        }
hgs
parents:
diff changeset
   262
        break;
hgs
parents:
diff changeset
   263
hgs
parents:
diff changeset
   264
        case EMsvEntriesDeleted:
hgs
parents:
diff changeset
   265
        {
hgs
parents:
diff changeset
   266
            for (TInt i = 0; i < selection->Count(); i++)
hgs
parents:
diff changeset
   267
            {
hgs
parents:
diff changeset
   268
                RSqlStatement sqlDeleteStmt;
hgs
parents:
diff changeset
   269
                CleanupClosePushL(sqlDeleteStmt);
hgs
parents:
diff changeset
   270
                sqlDeleteStmt.PrepareL(iSqlDb, KRemoveMsgStmnt);
hgs
parents:
diff changeset
   271
hgs
parents:
diff changeset
   272
                TInt messageIdIndex = sqlDeleteStmt.ParameterIndex(_L(
hgs
parents:
diff changeset
   273
                    ":message_id"));
hgs
parents:
diff changeset
   274
                User::LeaveIfError(sqlDeleteStmt.BindInt(messageIdIndex, selection->At(i)));
hgs
parents:
diff changeset
   275
hgs
parents:
diff changeset
   276
                User::LeaveIfError(sqlDeleteStmt.Exec());
hgs
parents:
diff changeset
   277
                CleanupStack::PopAndDestroy(&sqlDeleteStmt);
hgs
parents:
diff changeset
   278
            }
hgs
parents:
diff changeset
   279
        }
hgs
parents:
diff changeset
   280
        break;
hgs
parents:
diff changeset
   281
    }
hgs
parents:
diff changeset
   282
hgs
parents:
diff changeset
   283
    PRINT ( _L("Exit CCsPreviewPluginHandler::HandleSessionEventL") );
hgs
parents:
diff changeset
   284
}
hgs
parents:
diff changeset
   285
hgs
parents:
diff changeset
   286
// ---------------------------------------------------------------------
hgs
parents:
diff changeset
   287
// CCsPreviewPluginHandler::HandleEvent
hgs
parents:
diff changeset
   288
// Handle events
hgs
parents:
diff changeset
   289
// ---------------------------------------------------------------------
hgs
parents:
diff changeset
   290
//
hgs
parents:
diff changeset
   291
void CCsPreviewPluginHandler::HandleEventL(CMsvEntrySelection* aSelection)
hgs
parents:
diff changeset
   292
{
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   293
    PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent start.") );
37
hgs
parents:
diff changeset
   294
hgs
parents:
diff changeset
   295
    TMsvEntry entry;
hgs
parents:
diff changeset
   296
    TMsvId service;
hgs
parents:
diff changeset
   297
    TInt error = KErrNone;
hgs
parents:
diff changeset
   298
hgs
parents:
diff changeset
   299
    for (TInt i = 0; i < aSelection->Count(); i++)
hgs
parents:
diff changeset
   300
    {
hgs
parents:
diff changeset
   301
        error = iSession->GetEntry(aSelection->At(i), service, entry);
hgs
parents:
diff changeset
   302
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   303
        if ((KErrNone == error) && !entry.InPreparation() && entry.Visible())
37
hgs
parents:
diff changeset
   304
        {
hgs
parents:
diff changeset
   305
            PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") );
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   306
            if ((KSenduiMtmMmsUidValue == entry.iMtm.iUid))
37
hgs
parents:
diff changeset
   307
                {
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   308
                HandleMMSEntryL(entry);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   309
                }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   310
            else if ((KSenduiMtmSmsUidValue == entry.iMtm.iUid) || (KSenduiMtmBioUidValue == entry.iMtm.iUid))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   311
                {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   312
                if ((KMsgBioUidVCard.iUid == entry.iBioType))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   313
                    {                 
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   314
                    HandleVCardEntryL(entry);
37
hgs
parents:
diff changeset
   315
                    }
hgs
parents:
diff changeset
   316
                }
hgs
parents:
diff changeset
   317
            }
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   318
        }//end for loop
37
hgs
parents:
diff changeset
   319
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   320
    PRINT ( _L("Exit CCsPreviewPluginHandler::HandleEvent end.") );
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   321
    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   322
// -----------------------------------------------------------------------------
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   323
// CCsPreviewPluginHandler::HandleMMSEntryL()
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   324
// 
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   325
// -----------------------------------------------------------------------------
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   326
//
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   327
void CCsPreviewPluginHandler::HandleMMSEntryL(const TMsvEntry& aEntry)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   328
    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   329
    PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry start.") );
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   330
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   331
    TInt msgId = aEntry.Id();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   332
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   333
    // check if the msg is already under processing Or processed
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   334
    if (EPreviewMsgNotProcessed != msgProcessingState(msgId))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   335
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   336
        // skip processing this event for the given message
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   337
        return;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   338
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   339
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   340
    // start processing message, set flag
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   341
    setMsgProcessingState(msgId, EPreviewMsgProcessing);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   342
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   343
    // update db with message preview data
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   344
    RSqlStatement sqlInsertStmt;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   345
    CleanupClosePushL(sqlInsertStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   346
    sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   347
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   348
    // parse message
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   349
    iMmsMtm->SwitchCurrentEntryL(msgId);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   350
    iMmsMtm->LoadMessageL();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   351
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   352
    CUniDataModel* iUniDataModel = CUniDataModel::NewL(ifsSession, *iMmsMtm);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   353
    CleanupStack::PushL(iUniDataModel);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   354
    iUniDataModel->RestoreL(*this, ETrue);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   355
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   356
    //msg property
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   357
    TInt msgProperty = 0;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   358
    if (iUniDataModel->AttachmentList().Count() > 0)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   359
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   360
        msgProperty |= EPreviewAttachment;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   361
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   362
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   363
    //check for msg forward
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   364
    //Validate if the mms msg can be forwarded or not
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   365
    if (ValidateMsgForForward(iUniDataModel))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   366
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   367
        msgProperty |= EPreviewForward;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   368
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   369
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   370
    TPtrC videoPath;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   371
    TPtrC imagePath;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   372
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   373
    // preview parsing
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   374
    TInt slideCount = iUniDataModel->SmilModel().SlideCount();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   375
    TBool isBodyTextSet = EFalse;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   376
    TBool isImageSet = EFalse;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   377
    TBool isAudioSet = EFalse;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   378
    TBool isVideoSet = EFalse;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   379
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   380
    for (int i = 0; i < slideCount; i++)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   381
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   382
        int slideobjcount = iUniDataModel->SmilModel().SlideObjectCount(i);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   383
        for (int j = 0; j < slideobjcount; j++)
37
hgs
parents:
diff changeset
   384
            {
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   385
            CUniObject *obj = iUniDataModel->SmilModel(). GetObjectByIndex(i,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   386
                    j);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   387
            CMsgMediaInfo *mediaInfo = obj->MediaInfo();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   388
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   389
            TPtrC8 mimetype = obj->MimeType();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   390
            TMsvAttachmentId attachId = obj->AttachmentId();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   391
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   392
            //bodytext
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   393
            if (!isBodyTextSet
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   394
                    && (mimetype.Find(_L8("text")) != KErrNotFound))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   395
                {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   396
                //bind bodytext into statement
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   397
                BindBodyText(sqlInsertStmt, attachId);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   398
                isBodyTextSet = ETrue;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   399
                }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   400
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   401
            //image parsing
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   402
            if (!isVideoSet && !isImageSet && (mimetype.Find(_L8("image"))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   403
                    != KErrNotFound))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   404
                {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   405
                //get thumbnail for this image
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   406
                isImageSet = ETrue;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   407
                imagePath.Set(mediaInfo->FullFilePath());
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   408
                msgProperty |= EPreviewImage;
37
hgs
parents:
diff changeset
   409
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   410
                if (EFileProtNoProtection != mediaInfo->Protection())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   411
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   412
                    msgProperty |= EPreviewProtectedImage;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   413
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   414
                if (mediaInfo->Corrupt())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   415
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   416
                    msgProperty |= EPreviewCorruptedImage;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   417
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   418
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   419
                if (!(EPreviewProtectedImage & msgProperty)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   420
                        && !(EPreviewCorruptedImage & msgProperty))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   421
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   422
                    //Generate thumbnail for non protected,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   423
                    //non corrupted image.
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   424
                    GetThumbNailL(attachId, mimetype, msgId);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   425
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   426
                }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   427
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   428
            //audio content
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   429
            if (!isVideoSet && !isAudioSet && (mimetype.Find(_L8("audio"))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   430
                    != KErrNotFound))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   431
                {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   432
                isAudioSet = ETrue;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   433
                msgProperty |= EPreviewAudio;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   434
                if (EFileProtNoProtection != mediaInfo->Protection())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   435
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   436
                    msgProperty |= EPreviewProtectedAudio;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   437
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   438
                if (mediaInfo->Corrupt())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   439
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   440
                    msgProperty |= EPreviewCorruptedAudio;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   441
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   442
                }
37
hgs
parents:
diff changeset
   443
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   444
            //video content
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   445
            if (!(isImageSet || isAudioSet) && !isVideoSet && (mimetype.Find(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   446
                    _L8("video")) != KErrNotFound))
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   447
                {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   448
                videoPath.Set(mediaInfo->FullFilePath());
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   449
                isVideoSet = ETrue;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   450
                msgProperty |= EPreviewVideo;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   451
                if (EFileProtNoProtection != mediaInfo->Protection())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   452
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   453
                    msgProperty |= EPreviewProtectedVideo;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   454
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   455
                if (mediaInfo->Corrupt())
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   456
                    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   457
                    msgProperty |= EPreviewCorruptedVideo;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   458
                    }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   459
                }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   460
            }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   461
        }
37
hgs
parents:
diff changeset
   462
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   463
    //set preview path
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   464
    TInt previewPathIndex = sqlInsertStmt.ParameterIndex(_L(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   465
            ":preview_path"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   466
    if (isVideoSet)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   467
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   468
        User::LeaveIfError(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   469
                sqlInsertStmt.BindText(previewPathIndex, videoPath));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   470
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   471
    else if (isImageSet)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   472
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   473
        User::LeaveIfError(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   474
                sqlInsertStmt.BindText(previewPathIndex, imagePath));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   475
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   476
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   477
    //msg_id
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   478
    TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   479
    User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   480
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   481
    //subjext
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   482
    TInt subjectIndex = sqlInsertStmt.ParameterIndex(_L(":subject"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   483
    User::LeaveIfError(sqlInsertStmt.BindText(subjectIndex,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   484
            iMmsMtm->SubjectL()));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   485
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   486
    //msg_property
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   487
    TInt msgPropertyIndex = sqlInsertStmt.ParameterIndex(_L(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   488
            ":msg_property"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   489
    User::LeaveIfError(sqlInsertStmt.BindInt(msgPropertyIndex, msgProperty));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   490
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   491
    //msg_processingstate
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   492
    TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   493
            _L(":msg_processingstate"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   494
    User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   495
            EPreviewMsgProcessed));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   496
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   497
    //execute sql stament
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   498
    User::LeaveIfError(sqlInsertStmt.Exec());
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   499
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   500
    //cleanup
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   501
    CleanupStack::PopAndDestroy(2, &sqlInsertStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   502
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   503
    PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry end.") );
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   504
    }
37
hgs
parents:
diff changeset
   505
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   506
// -----------------------------------------------------------------------------
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   507
// CCsPreviewPluginHandler::HandleVCardEntryL()
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   508
// 
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   509
// -----------------------------------------------------------------------------
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   510
//
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   511
void CCsPreviewPluginHandler::HandleVCardEntryL(const TMsvEntry& aEntry)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   512
    {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   513
    PRINT ( _L("Enter CCsPreviewPluginHandler::HandleBioMsgEntry start.") );
37
hgs
parents:
diff changeset
   514
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   515
    TMsvId msgId = aEntry.Id();   
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   516
    
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   517
    // check if the msg is already under processing Or processed
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   518
    TInt msgProcessState = EPreviewMsgNotProcessed;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   519
    msgProcessState = msgProcessingState(msgId);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   520
    if (EPreviewMsgProcessed == msgProcessState)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   521
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   522
        return;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   523
        }
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   524
    //get attachments
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   525
    CMsvEntry* cMsvEntry = CMsvEntry::NewL(iBioClientMtm->Session(), msgId,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   526
               TMsvSelectionOrdering());
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   527
    
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   528
    CleanupStack::PushL(cMsvEntry);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   529
    CMsvStore* store = cMsvEntry->ReadStoreL();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   530
    CleanupStack::PushL(store);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   531
    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
37
hgs
parents:
diff changeset
   532
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   533
    TInt attachmentCount = attachMan.AttachmentCount();
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   534
    if (attachmentCount)
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   535
        {
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   536
        // get attachment file path
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   537
        RFile file = attachMan.GetAttachmentFileL(0);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   538
        CleanupClosePushL(file);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   539
        TFileName fullName;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   540
        User::LeaveIfError(file.FullName(fullName));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   541
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   542
        // update db with meta-data
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   543
        RSqlStatement sqlInsertStmt;
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   544
        CleanupClosePushL(sqlInsertStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   545
        sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertBioMsgStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   546
       
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   547
        //msg_id
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   548
        TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   549
        User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   550
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   551
        //set attachment path
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   552
        TInt previewPathIndex = sqlInsertStmt.ParameterIndex(_L(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   553
                ":preview_path"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   554
        User::LeaveIfError(sqlInsertStmt.BindText(previewPathIndex, fullName));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   555
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   556
        //msg_processingstate
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   557
        TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex(
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   558
                _L(":msg_processingstate"));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   559
        User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex,
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   560
                EPreviewMsgProcessed));
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   561
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   562
        //execute sql stament
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   563
        User::LeaveIfError(sqlInsertStmt.Exec());
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   564
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   565
        //cleanup
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   566
        CleanupStack::PopAndDestroy(&sqlInsertStmt);
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   567
        CleanupStack::PopAndDestroy(&file);
37
hgs
parents:
diff changeset
   568
        }
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   569
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   570
    CleanupStack::PopAndDestroy(2, cMsvEntry);//cMsvEntry,store
37
hgs
parents:
diff changeset
   571
48
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   572
    PRINT ( _L("Enter CCsPreviewPluginHandler::HandleBioMsgEntry End.") );
4f501b74aeb1 201029_02
hgs
parents: 37
diff changeset
   573
    }
37
hgs
parents:
diff changeset
   574
hgs
parents:
diff changeset
   575
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   576
// CCsPreviewPluginHandler::RestoreReady()
hgs
parents:
diff changeset
   577
// 
hgs
parents:
diff changeset
   578
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   579
//
hgs
parents:
diff changeset
   580
void CCsPreviewPluginHandler::RestoreReady(TInt /*aParseResult*/, TInt /*aError*/)
hgs
parents:
diff changeset
   581
{
hgs
parents:
diff changeset
   582
hgs
parents:
diff changeset
   583
}
hgs
parents:
diff changeset
   584
hgs
parents:
diff changeset
   585
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   586
// CCsPreviewPluginHandler::ThumbnailReady()
hgs
parents:
diff changeset
   587
// 
hgs
parents:
diff changeset
   588
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   589
//
hgs
parents:
diff changeset
   590
void CCsPreviewPluginHandler::ThumbnailReady(TInt aError,
hgs
parents:
diff changeset
   591
    MThumbnailData& aThumbnail, TThumbnailRequestId aId)
hgs
parents:
diff changeset
   592
{
hgs
parents:
diff changeset
   593
    // This function must not leave.
hgs
parents:
diff changeset
   594
    if (!aError)
hgs
parents:
diff changeset
   595
    {
hgs
parents:
diff changeset
   596
        PRINT ( _L("CCsPreviewPluginHandler::ThumbnailReady received.") );
hgs
parents:
diff changeset
   597
        TInt err;
hgs
parents:
diff changeset
   598
        TRAP(err, HandleThumbnailReadyL(aThumbnail, aId));
hgs
parents:
diff changeset
   599
        PRINT1 ( _L("CCsPreviewPluginHandler::ThumbnailReady handling error= %d."), err );
hgs
parents:
diff changeset
   600
    }
hgs
parents:
diff changeset
   601
    else
hgs
parents:
diff changeset
   602
    {
hgs
parents:
diff changeset
   603
        // An error occurred while getting the thumbnail.
hgs
parents:
diff changeset
   604
        PRINT1 ( _L("End CCsPreviewPluginHandler::ThumbnailReady error= %d."), aError );
hgs
parents:
diff changeset
   605
    }
hgs
parents:
diff changeset
   606
}
hgs
parents:
diff changeset
   607
hgs
parents:
diff changeset
   608
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   609
// CCsPreviewPluginHandler::ThumbnailPreviewReady()
hgs
parents:
diff changeset
   610
// callback
hgs
parents:
diff changeset
   611
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   612
//
hgs
parents:
diff changeset
   613
void CCsPreviewPluginHandler::ThumbnailPreviewReady(
hgs
parents:
diff changeset
   614
    MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/)
hgs
parents:
diff changeset
   615
{
hgs
parents:
diff changeset
   616
hgs
parents:
diff changeset
   617
}
hgs
parents:
diff changeset
   618
hgs
parents:
diff changeset
   619
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   620
// CCsPreviewPluginHandler::HandleThumbnailReadyL()
hgs
parents:
diff changeset
   621
// 
hgs
parents:
diff changeset
   622
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   623
//
hgs
parents:
diff changeset
   624
void CCsPreviewPluginHandler::HandleThumbnailReadyL(MThumbnailData& aThumbnail,
hgs
parents:
diff changeset
   625
    TThumbnailRequestId aId)
hgs
parents:
diff changeset
   626
{
hgs
parents:
diff changeset
   627
    //match response to request
hgs
parents:
diff changeset
   628
    ThumbnailRequestData tempObj;
hgs
parents:
diff changeset
   629
    tempObj.iRequestId = aId;
hgs
parents:
diff changeset
   630
hgs
parents:
diff changeset
   631
    TInt index = iThumbnailRequestArray.Find(tempObj,
hgs
parents:
diff changeset
   632
        CCsPreviewPluginHandler::CompareByRequestId);
hgs
parents:
diff changeset
   633
    if (index < 0)
hgs
parents:
diff changeset
   634
    {
hgs
parents:
diff changeset
   635
        PRINT ( _L("End CCsPreviewPluginHandler::HandleThumbnailReady request match not found.") );
hgs
parents:
diff changeset
   636
        return;
hgs
parents:
diff changeset
   637
    }
hgs
parents:
diff changeset
   638
hgs
parents:
diff changeset
   639
    // get msg-id corresponding to the request-id
hgs
parents:
diff changeset
   640
    TInt msgId = iThumbnailRequestArray[index].iMsgId;
hgs
parents:
diff changeset
   641
    //remove the request from requestarray
hgs
parents:
diff changeset
   642
    iThumbnailRequestArray.Remove(index);
hgs
parents:
diff changeset
   643
hgs
parents:
diff changeset
   644
    // get bitmap
hgs
parents:
diff changeset
   645
    CFbsBitmap* bitmap = aThumbnail.Bitmap();
hgs
parents:
diff changeset
   646
hgs
parents:
diff changeset
   647
    // sql-statment to set preview-icon
hgs
parents:
diff changeset
   648
    RSqlStatement sqlInsertStmt;
hgs
parents:
diff changeset
   649
    CleanupClosePushL(sqlInsertStmt);
hgs
parents:
diff changeset
   650
    sqlInsertStmt.PrepareL(iSqlDb, KSqlUpdateBitmapStmt);
hgs
parents:
diff changeset
   651
hgs
parents:
diff changeset
   652
    TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id"));
hgs
parents:
diff changeset
   653
    TInt previewIconIndex = sqlInsertStmt.ParameterIndex(_L(":preview_icon"));
hgs
parents:
diff changeset
   654
hgs
parents:
diff changeset
   655
    User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId));
hgs
parents:
diff changeset
   656
hgs
parents:
diff changeset
   657
    RSqlParamWriteStream previewIconStream;
hgs
parents:
diff changeset
   658
    CleanupClosePushL(previewIconStream);
hgs
parents:
diff changeset
   659
hgs
parents:
diff changeset
   660
    //bind data
hgs
parents:
diff changeset
   661
    User::LeaveIfError(previewIconStream.BindBinary(sqlInsertStmt, previewIconIndex));
hgs
parents:
diff changeset
   662
    bitmap->ExternalizeL(previewIconStream);
hgs
parents:
diff changeset
   663
    previewIconStream.CommitL();
hgs
parents:
diff changeset
   664
hgs
parents:
diff changeset
   665
    //execute the statent
hgs
parents:
diff changeset
   666
    User::LeaveIfError(sqlInsertStmt.Exec());
hgs
parents:
diff changeset
   667
hgs
parents:
diff changeset
   668
    CleanupStack::PopAndDestroy(2,&sqlInsertStmt);//sqlInsertStmt,previewIconStream
hgs
parents:
diff changeset
   669
}
hgs
parents:
diff changeset
   670
hgs
parents:
diff changeset
   671
TBool CCsPreviewPluginHandler::ValidateMsgForForward(CUniDataModel* aUniDataModel)
hgs
parents:
diff changeset
   672
{
hgs
parents:
diff changeset
   673
    TBool retValue = ETrue;
hgs
parents:
diff changeset
   674
hgs
parents:
diff changeset
   675
    //1. Check the slide count more than 1
hgs
parents:
diff changeset
   676
    if (aUniDataModel->SmilModel().SlideCount() > 1)
hgs
parents:
diff changeset
   677
    {
hgs
parents:
diff changeset
   678
        retValue = EFalse;
hgs
parents:
diff changeset
   679
        return retValue;
hgs
parents:
diff changeset
   680
    }
hgs
parents:
diff changeset
   681
hgs
parents:
diff changeset
   682
    //2. message sixe check
hgs
parents:
diff changeset
   683
    //Fetch and set max mms composition size
hgs
parents:
diff changeset
   684
    if (iMmsMtm->MessageSize() > iMaxMmsSize)
hgs
parents:
diff changeset
   685
    {
hgs
parents:
diff changeset
   686
        retValue = EFalse;
hgs
parents:
diff changeset
   687
        return retValue;
hgs
parents:
diff changeset
   688
    }
hgs
parents:
diff changeset
   689
hgs
parents:
diff changeset
   690
    //3. If there is restricted content then return false
hgs
parents:
diff changeset
   691
    RArray<TMsvAttachmentId>* pathList = GetSlideAttachmentIds(
hgs
parents:
diff changeset
   692
            0, 
hgs
parents:
diff changeset
   693
            aUniDataModel);
hgs
parents:
diff changeset
   694
    
hgs
parents:
diff changeset
   695
    CleanupStack::PushL(pathList);
hgs
parents:
diff changeset
   696
hgs
parents:
diff changeset
   697
    for (int i = 0; i < pathList->Count(); i++)
hgs
parents:
diff changeset
   698
    {
hgs
parents:
diff changeset
   699
        TMsvAttachmentId aId = (*pathList)[i];
hgs
parents:
diff changeset
   700
        CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
hgs
parents:
diff changeset
   701
        CleanupStack::PushL(store);
hgs
parents:
diff changeset
   702
        MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
hgs
parents:
diff changeset
   703
        RFile fileHandle = attachMan.GetAttachmentFileL(aId);
hgs
parents:
diff changeset
   704
        //close the store
hgs
parents:
diff changeset
   705
        CleanupStack::PopAndDestroy(store);
hgs
parents:
diff changeset
   706
hgs
parents:
diff changeset
   707
        if (CheckModeForInsertL(fileHandle) != EInsertSuccess)
hgs
parents:
diff changeset
   708
        {
hgs
parents:
diff changeset
   709
            retValue = EFalse;
hgs
parents:
diff changeset
   710
            break;
hgs
parents:
diff changeset
   711
        }
hgs
parents:
diff changeset
   712
    }
hgs
parents:
diff changeset
   713
hgs
parents:
diff changeset
   714
    if (retValue == EFalse)
hgs
parents:
diff changeset
   715
    {
hgs
parents:
diff changeset
   716
        CleanupStack::PopAndDestroy(pathList);
hgs
parents:
diff changeset
   717
        return retValue;
hgs
parents:
diff changeset
   718
    }
hgs
parents:
diff changeset
   719
hgs
parents:
diff changeset
   720
    CleanupStack::Pop(pathList);
hgs
parents:
diff changeset
   721
    delete pathList;
hgs
parents:
diff changeset
   722
    pathList = NULL;
hgs
parents:
diff changeset
   723
hgs
parents:
diff changeset
   724
    //4. check the same case for all attachments
hgs
parents:
diff changeset
   725
    pathList = GetAttachmentIdList(aUniDataModel);
hgs
parents:
diff changeset
   726
    CleanupStack::PushL(pathList);
hgs
parents:
diff changeset
   727
hgs
parents:
diff changeset
   728
    for (int i = 0; i < pathList->Count(); i++)
hgs
parents:
diff changeset
   729
    {
hgs
parents:
diff changeset
   730
        TMsvAttachmentId aId = (*pathList)[i];
hgs
parents:
diff changeset
   731
        CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
hgs
parents:
diff changeset
   732
        CleanupStack::PushL(store);
hgs
parents:
diff changeset
   733
        MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
hgs
parents:
diff changeset
   734
        RFile fileHandle = attachMan.GetAttachmentFileL(aId);
hgs
parents:
diff changeset
   735
        //close the store
hgs
parents:
diff changeset
   736
        CleanupStack::PopAndDestroy(store);
hgs
parents:
diff changeset
   737
        
hgs
parents:
diff changeset
   738
        if (CheckModeForInsertL(fileHandle) != EInsertSuccess)
hgs
parents:
diff changeset
   739
        {
hgs
parents:
diff changeset
   740
            retValue = EFalse;
hgs
parents:
diff changeset
   741
            break;
hgs
parents:
diff changeset
   742
        }
hgs
parents:
diff changeset
   743
    }
hgs
parents:
diff changeset
   744
hgs
parents:
diff changeset
   745
    CleanupStack::PopAndDestroy(pathList);
hgs
parents:
diff changeset
   746
    return retValue;
hgs
parents:
diff changeset
   747
}
hgs
parents:
diff changeset
   748
hgs
parents:
diff changeset
   749
RArray<TMsvAttachmentId>*
hgs
parents:
diff changeset
   750
CCsPreviewPluginHandler::GetSlideAttachmentIds(TInt aSlideNum,
hgs
parents:
diff changeset
   751
                                        CUniDataModel* aUniDataModel)
hgs
parents:
diff changeset
   752
{
hgs
parents:
diff changeset
   753
    TInt slideObjectCount =
hgs
parents:
diff changeset
   754
            aUniDataModel->SmilModel().SlideObjectCount(aSlideNum);
hgs
parents:
diff changeset
   755
hgs
parents:
diff changeset
   756
    RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray<
hgs
parents:
diff changeset
   757
            TMsvAttachmentId> ();
hgs
parents:
diff changeset
   758
    for (TInt i = 0; i < slideObjectCount; i++)
hgs
parents:
diff changeset
   759
    {
hgs
parents:
diff changeset
   760
        CUniObject *obj =
hgs
parents:
diff changeset
   761
                aUniDataModel->SmilModel().GetObjectByIndex(aSlideNum, i);
hgs
parents:
diff changeset
   762
        attachmentIdList->Append(obj->AttachmentId());
hgs
parents:
diff changeset
   763
    }
hgs
parents:
diff changeset
   764
    return attachmentIdList;
hgs
parents:
diff changeset
   765
}
hgs
parents:
diff changeset
   766
hgs
parents:
diff changeset
   767
RArray<TMsvAttachmentId>*
hgs
parents:
diff changeset
   768
CCsPreviewPluginHandler::GetAttachmentIdList(CUniDataModel* aUniDataModel)
hgs
parents:
diff changeset
   769
{
hgs
parents:
diff changeset
   770
    TInt attcount = aUniDataModel->AttachmentList().Count();
hgs
parents:
diff changeset
   771
    RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray<
hgs
parents:
diff changeset
   772
            TMsvAttachmentId> ();
hgs
parents:
diff changeset
   773
hgs
parents:
diff changeset
   774
    for (TInt i = 0; i < attcount; i++)
hgs
parents:
diff changeset
   775
    {
hgs
parents:
diff changeset
   776
        CUniObject *obj = aUniDataModel->AttachmentList().GetByIndex(i);
hgs
parents:
diff changeset
   777
hgs
parents:
diff changeset
   778
        attachmentIdList->AppendL(obj->AttachmentId());
hgs
parents:
diff changeset
   779
    }
hgs
parents:
diff changeset
   780
    return attachmentIdList;
hgs
parents:
diff changeset
   781
}
hgs
parents:
diff changeset
   782
hgs
parents:
diff changeset
   783
TInt CCsPreviewPluginHandler::CheckModeForInsertL(RFile aFileHandle)
hgs
parents:
diff changeset
   784
{
hgs
parents:
diff changeset
   785
    CleanupClosePushL(aFileHandle);
hgs
parents:
diff changeset
   786
hgs
parents:
diff changeset
   787
    CMmsConformance* mmsConformance = CMmsConformance::NewL();
hgs
parents:
diff changeset
   788
    mmsConformance->CheckCharacterSet(EFalse);
hgs
parents:
diff changeset
   789
hgs
parents:
diff changeset
   790
    CleanupStack::PushL(mmsConformance);
hgs
parents:
diff changeset
   791
hgs
parents:
diff changeset
   792
    CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL();
hgs
parents:
diff changeset
   793
    mediaResolver->SetCharacterSetRecognition(EFalse);
hgs
parents:
diff changeset
   794
hgs
parents:
diff changeset
   795
    CleanupStack::PushL(mediaResolver);
hgs
parents:
diff changeset
   796
hgs
parents:
diff changeset
   797
    CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(aFileHandle);
hgs
parents:
diff changeset
   798
    mediaResolver->ParseInfoDetailsL(info, aFileHandle);
hgs
parents:
diff changeset
   799
hgs
parents:
diff changeset
   800
    TMmsConformance conformance = mmsConformance->MediaConformance(*info);
hgs
parents:
diff changeset
   801
    iConfStatus = conformance.iConfStatus;
hgs
parents:
diff changeset
   802
hgs
parents:
diff changeset
   803
    CleanupStack::PopAndDestroy(3);
hgs
parents:
diff changeset
   804
hgs
parents:
diff changeset
   805
    // In "free" mode user can insert images that are larger by dimensions than allowed by conformance
hgs
parents:
diff changeset
   806
    if (iCreationMode != EMmsCreationModeRestricted)
hgs
parents:
diff changeset
   807
    {
hgs
parents:
diff changeset
   808
        TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
hgs
parents:
diff changeset
   809
                | EMmsConfNokTooBig;
hgs
parents:
diff changeset
   810
        TInt j = ~ (EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
hgs
parents:
diff changeset
   811
                | EMmsConfNokTooBig);
hgs
parents:
diff changeset
   812
hgs
parents:
diff changeset
   813
        // If user answers yes to Guided mode confirmation query he/she moves to free mode
hgs
parents:
diff changeset
   814
        if ( (iConfStatus & i) && ! (iConfStatus & j))
hgs
parents:
diff changeset
   815
        {
hgs
parents:
diff changeset
   816
            if (iCreationMode == EMmsCreationModeFree || info->Protection()
hgs
parents:
diff changeset
   817
                    & EFileProtSuperDistributable)
hgs
parents:
diff changeset
   818
            {
hgs
parents:
diff changeset
   819
                // SuperDistribution not checked here
hgs
parents:
diff changeset
   820
                // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
hgs
parents:
diff changeset
   821
                iConfStatus &= ~EMmsConfNokFreeModeOnly;
hgs
parents:
diff changeset
   822
                iConfStatus &= ~EMmsConfNokScalingNeeded;
hgs
parents:
diff changeset
   823
            }
hgs
parents:
diff changeset
   824
            else
hgs
parents:
diff changeset
   825
            {
hgs
parents:
diff changeset
   826
                delete info;
hgs
parents:
diff changeset
   827
                //query not accepted. Stop insertion.
hgs
parents:
diff changeset
   828
                return EInsertQueryAbort;
hgs
parents:
diff changeset
   829
            }
hgs
parents:
diff changeset
   830
        }
hgs
parents:
diff changeset
   831
    }
hgs
parents:
diff changeset
   832
    else if (iConfStatus & EMmsConfNokDRM || iConfStatus
hgs
parents:
diff changeset
   833
            & EMmsConfNokNotEnoughInfo || iConfStatus & EMmsConfNokNotSupported
hgs
parents:
diff changeset
   834
            || iConfStatus & EMmsConfNokFreeModeOnly || iConfStatus
hgs
parents:
diff changeset
   835
            & EMmsConfNokCorrupt)
hgs
parents:
diff changeset
   836
    {
hgs
parents:
diff changeset
   837
        delete info;
hgs
parents:
diff changeset
   838
        return EInsertNotSupported;
hgs
parents:
diff changeset
   839
    }
hgs
parents:
diff changeset
   840
hgs
parents:
diff changeset
   841
    delete info;
hgs
parents:
diff changeset
   842
    return EInsertSuccess;
hgs
parents:
diff changeset
   843
}
hgs
parents:
diff changeset
   844
hgs
parents:
diff changeset
   845
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   846
// CCsPreviewPluginHandler::CompareByRequestId
hgs
parents:
diff changeset
   847
// Compare to conversation entry object based on Entry Ids
hgs
parents:
diff changeset
   848
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   849
TBool CCsPreviewPluginHandler::CompareByRequestId(
hgs
parents:
diff changeset
   850
    const ThumbnailRequestData& aFirst, const ThumbnailRequestData& aSecond)
hgs
parents:
diff changeset
   851
{
hgs
parents:
diff changeset
   852
    if (aFirst.iRequestId == aSecond.iRequestId)
hgs
parents:
diff changeset
   853
        return ETrue;
hgs
parents:
diff changeset
   854
hgs
parents:
diff changeset
   855
    return EFalse;
hgs
parents:
diff changeset
   856
}
hgs
parents:
diff changeset
   857
hgs
parents:
diff changeset
   858
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   859
// CCsPreviewPluginHandler::BindBodyText()
hgs
parents:
diff changeset
   860
// 
hgs
parents:
diff changeset
   861
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   862
//
hgs
parents:
diff changeset
   863
void CCsPreviewPluginHandler::BindBodyText(RSqlStatement& sqlStmt,
hgs
parents:
diff changeset
   864
    TMsvAttachmentId attachmentId)
hgs
parents:
diff changeset
   865
{
hgs
parents:
diff changeset
   866
    //get file handle from attachmnet manager.
hgs
parents:
diff changeset
   867
    CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
hgs
parents:
diff changeset
   868
    CleanupStack::PushL(store);
hgs
parents:
diff changeset
   869
    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
hgs
parents:
diff changeset
   870
    RFile file = attachMan.GetAttachmentFileL(attachmentId);
hgs
parents:
diff changeset
   871
    CleanupClosePushL(file);
hgs
parents:
diff changeset
   872
hgs
parents:
diff changeset
   873
    //read file contents to buffer
hgs
parents:
diff changeset
   874
    TInt length;
hgs
parents:
diff changeset
   875
    file.Size(length);
hgs
parents:
diff changeset
   876
    HBufC8* bodyText = HBufC8::NewLC(length);
hgs
parents:
diff changeset
   877
    TPtr8 textBuffer = bodyText->Des();
hgs
parents:
diff changeset
   878
    file.Read(textBuffer);
hgs
parents:
diff changeset
   879
hgs
parents:
diff changeset
   880
    // convert from HBufC8 to HBufC16
hgs
parents:
diff changeset
   881
    HBufC16 *text16 = HBufC16::NewLC(textBuffer.Length());
hgs
parents:
diff changeset
   882
    TPtr16 textPtr16 = text16->Des();
hgs
parents:
diff changeset
   883
    CnvUtfConverter::ConvertToUnicodeFromUtf8(textPtr16, textBuffer);
hgs
parents:
diff changeset
   884
hgs
parents:
diff changeset
   885
    //set bodytext in the sql statement
hgs
parents:
diff changeset
   886
    TInt bodyTextIndex = sqlStmt.ParameterIndex(_L(":body_text"));
hgs
parents:
diff changeset
   887
    sqlStmt.BindText(bodyTextIndex, textPtr16);
hgs
parents:
diff changeset
   888
hgs
parents:
diff changeset
   889
    CleanupStack::PopAndDestroy(4, store); //store,file, bodyText, text16
hgs
parents:
diff changeset
   890
}
hgs
parents:
diff changeset
   891
hgs
parents:
diff changeset
   892
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   893
// CCsPreviewPluginHandler::GetThumbNailL()
hgs
parents:
diff changeset
   894
// 
hgs
parents:
diff changeset
   895
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   896
//
hgs
parents:
diff changeset
   897
void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId,
hgs
parents:
diff changeset
   898
    TDesC8& mimeType, TMsvId msgId)
hgs
parents:
diff changeset
   899
{
hgs
parents:
diff changeset
   900
    //Scale the image
hgs
parents:
diff changeset
   901
    iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio);
hgs
parents:
diff changeset
   902
hgs
parents:
diff changeset
   903
    //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels
hgs
parents:
diff changeset
   904
    iThumbnailManager->SetThumbnailSizeL(TSize(KWidth, KHeight)); 
hgs
parents:
diff changeset
   905
    
hgs
parents:
diff changeset
   906
    //optimize for performace
hgs
parents:
diff changeset
   907
    iThumbnailManager->SetQualityPreferenceL(
hgs
parents:
diff changeset
   908
        CThumbnailManager::EOptimizeForPerformance);
hgs
parents:
diff changeset
   909
hgs
parents:
diff changeset
   910
    // Create Thumbnail object source representing a path to a file
hgs
parents:
diff changeset
   911
    HBufC* mimeInfo = HBufC::NewLC(mimeType.Length());
hgs
parents:
diff changeset
   912
    mimeInfo->Des().Copy(mimeType);
hgs
parents:
diff changeset
   913
hgs
parents:
diff changeset
   914
    CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
hgs
parents:
diff changeset
   915
    CleanupStack::PushL(store);
hgs
parents:
diff changeset
   916
hgs
parents:
diff changeset
   917
    //get file handle from attachment manager.
hgs
parents:
diff changeset
   918
    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
hgs
parents:
diff changeset
   919
    RFile file = attachMan.GetAttachmentFileL(attachmentId);
hgs
parents:
diff changeset
   920
    CleanupClosePushL(file);
hgs
parents:
diff changeset
   921
hgs
parents:
diff changeset
   922
    CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(
hgs
parents:
diff changeset
   923
        (RFile64&) file, mimeInfo->Des());
hgs
parents:
diff changeset
   924
hgs
parents:
diff changeset
   925
    // Issue the request for thumbnail creation
hgs
parents:
diff changeset
   926
    ThumbnailRequestData reqObject;
hgs
parents:
diff changeset
   927
    reqObject.iMsgId = msgId;
hgs
parents:
diff changeset
   928
    reqObject.iRequestId = iThumbnailManager->GetThumbnailL(*source);
hgs
parents:
diff changeset
   929
    iThumbnailRequestArray.Append(reqObject);
hgs
parents:
diff changeset
   930
hgs
parents:
diff changeset
   931
    CleanupStack::PopAndDestroy(4, mimeInfo);//mimeInfo,store,file,source
hgs
parents:
diff changeset
   932
}
hgs
parents:
diff changeset
   933
hgs
parents:
diff changeset
   934
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   935
// CCsPreviewPluginHandler::msgProcessingState
hgs
parents:
diff changeset
   936
// 
hgs
parents:
diff changeset
   937
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   938
//
hgs
parents:
diff changeset
   939
TInt CCsPreviewPluginHandler::msgProcessingState(TMsvId aMsgId)
hgs
parents:
diff changeset
   940
{
hgs
parents:
diff changeset
   941
    TInt retState = EPreviewMsgNotProcessed;
hgs
parents:
diff changeset
   942
hgs
parents:
diff changeset
   943
    // sql-statement to check if msg's under processing flag is set or not
hgs
parents:
diff changeset
   944
    RSqlStatement sqlSelectStmt;
hgs
parents:
diff changeset
   945
    CleanupClosePushL(sqlSelectStmt);
hgs
parents:
diff changeset
   946
    sqlSelectStmt.PrepareL(iSqlDb,KSelectProcessingStateStmt);
hgs
parents:
diff changeset
   947
hgs
parents:
diff changeset
   948
    TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id"));
hgs
parents:
diff changeset
   949
    User::LeaveIfError(sqlSelectStmt.BindInt(msgIdIndex, aMsgId));
hgs
parents:
diff changeset
   950
hgs
parents:
diff changeset
   951
    // read the flag
hgs
parents:
diff changeset
   952
    TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex(_L("msg_processingstate"));
hgs
parents:
diff changeset
   953
    if (sqlSelectStmt.Next() == KSqlAtRow)
hgs
parents:
diff changeset
   954
    {
hgs
parents:
diff changeset
   955
         retState = static_cast<TInt>(sqlSelectStmt.ColumnInt(msgProcessingStateIndex));
hgs
parents:
diff changeset
   956
    }
hgs
parents:
diff changeset
   957
    else
hgs
parents:
diff changeset
   958
    {
hgs
parents:
diff changeset
   959
        // this is first event for this msgid, hence record doesn't exist
hgs
parents:
diff changeset
   960
        // create an empty record, so that we can set & use flags
hgs
parents:
diff changeset
   961
        RSqlStatement sqlBasicInsertStmt;
hgs
parents:
diff changeset
   962
        CleanupClosePushL(sqlBasicInsertStmt);
hgs
parents:
diff changeset
   963
        sqlBasicInsertStmt.PrepareL(iSqlDb, KSqlBasicInsertStmt);
hgs
parents:
diff changeset
   964
        TInt index_msgid = sqlBasicInsertStmt.ParameterIndex(_L(":message_id"));
hgs
parents:
diff changeset
   965
        User::LeaveIfError(sqlBasicInsertStmt.BindInt(index_msgid, aMsgId));
hgs
parents:
diff changeset
   966
        User::LeaveIfError(sqlBasicInsertStmt.Exec());
hgs
parents:
diff changeset
   967
        CleanupStack::PopAndDestroy(&sqlBasicInsertStmt);
hgs
parents:
diff changeset
   968
    }
hgs
parents:
diff changeset
   969
    // cleanup
hgs
parents:
diff changeset
   970
    CleanupStack::PopAndDestroy(&sqlSelectStmt);
hgs
parents:
diff changeset
   971
    return retState;
hgs
parents:
diff changeset
   972
}
hgs
parents:
diff changeset
   973
hgs
parents:
diff changeset
   974
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   975
// CCsPreviewPluginHandler::setMsgProcessingState
hgs
parents:
diff changeset
   976
// 
hgs
parents:
diff changeset
   977
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   978
//
hgs
parents:
diff changeset
   979
void CCsPreviewPluginHandler::setMsgProcessingState(TMsvId aMsgId, TInt aState)
hgs
parents:
diff changeset
   980
{
hgs
parents:
diff changeset
   981
    // sql-statment to set/reset msg's under processing flag
hgs
parents:
diff changeset
   982
    RSqlStatement sqlUpdateStmt;
hgs
parents:
diff changeset
   983
    CleanupClosePushL(sqlUpdateStmt);
hgs
parents:
diff changeset
   984
    sqlUpdateStmt.PrepareL(iSqlDb, KSqlUpdateProcessingStateStmt);
hgs
parents:
diff changeset
   985
hgs
parents:
diff changeset
   986
    TInt msgIdIndex = sqlUpdateStmt.ParameterIndex(_L(":message_id"));
hgs
parents:
diff changeset
   987
    User::LeaveIfError(sqlUpdateStmt.BindInt(msgIdIndex, aMsgId));
hgs
parents:
diff changeset
   988
hgs
parents:
diff changeset
   989
    // bind data
hgs
parents:
diff changeset
   990
    TInt msgProcessingStateIndex = sqlUpdateStmt.ParameterIndex(_L(":msg_processingstate"));
hgs
parents:
diff changeset
   991
    User::LeaveIfError(sqlUpdateStmt.BindInt(msgProcessingStateIndex, aState));
hgs
parents:
diff changeset
   992
hgs
parents:
diff changeset
   993
    // execute the statement
hgs
parents:
diff changeset
   994
    User::LeaveIfError(sqlUpdateStmt.Exec());
hgs
parents:
diff changeset
   995
    // cleanup
hgs
parents:
diff changeset
   996
    CleanupStack::PopAndDestroy(&sqlUpdateStmt);
hgs
parents:
diff changeset
   997
}
hgs
parents:
diff changeset
   998
hgs
parents:
diff changeset
   999
// End of file
hgs
parents:
diff changeset
  1000