messagingapp/msgui/appengine/src/conversationssummarymodel.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:09:17 +0300
changeset 43 35b64624a9e7
parent 34 84197e66a4bd
child 44 36f374c67aa8
permissions -rw-r--r--
Revision: 201023 Kit: 2010125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
 *
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
 *
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
 * Contributors:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
 *
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
 * Description:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
 *
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
 */
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
#include "conversationssummarymodel.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include "conversationsenginedefines.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include "conversationsengineutility.h"
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
    21
#include <xqconversions.h>
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include "convergedmessage.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include "unidatamodelloader.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include "unidatamodelplugininterface.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include "ringbc.h"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "msgcontacthandler.h"
34
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
    27
#include "debugtraces.h"
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
    28
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include <ccsclientconversation.h>
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include <ccsconversationentry.h>
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
#include <QFile>
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include <QFileInfo>
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
// ConversationsSummaryModel::ConversationsSummaryModel
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
ConversationsSummaryModel::ConversationsSummaryModel(QObject* parent)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
:QStandardItemModel(parent)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
// ConversationsSummaryModel::~ConversationsSummaryModel
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
ConversationsSummaryModel::~ConversationsSummaryModel()
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
{
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
}
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
// ConversationsSummaryModel::data
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
QVariant ConversationsSummaryModel::data(const QModelIndex & index , 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
    int role ) const
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
{
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
    QVariant value;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
    QStandardItem* item = itemFromIndex(index);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
    switch(role)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
        case ConversationId:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
            value = item->data(ConversationId);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
        case UnReadStatus:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
            value = item->data(UnReadStatus);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
        case ContactId:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
            value = item->data(ContactId);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
        case ConvergedMsgId:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
            value = item->data(ConvergedMsgId);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
        case UnreadCount:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
            value = item->data(UnreadCount);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
        case TimeStamp:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
            value = item->data(TimeStamp);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
        case SendingState:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
            value = item->data(SendingState);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
        case MessageProperty:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
            value = item->data(MessageProperty);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
        case MessageType:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
            value = item->data(MessageType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
        case MessageSubType:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
            value = item->data(MessageSubType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
        case Subject:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
            value = item->data(Subject);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
        case BodyText:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
            value = item->data(BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
        case ConversationAddress:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
            value = item->data(ConversationAddress);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
        case DisplayName:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
            value = item->data(DisplayName);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
        case Avatar:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
            value = item->data(Avatar);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
        case Direction:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
            value = item->data(Direction);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
        default:
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
            //No matching role found, set invalid variant.
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
            value = QVariant();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
            break;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
    return value;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
}
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
// ConversationsSummaryModel::addRow
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
void ConversationsSummaryModel::addRow(
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
        const CCsClientConversation& conversation)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
    {  
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
    int convId = conversation.GetConversationEntryId();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
    //match convId in model, if found update else add item
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
    QModelIndexList indexList = this->match(index(0, 0), 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
            ConversationId, 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
            convId, 1, Qt::MatchExactly);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
    // if not found, add new item
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
    if ( indexList.count() == 0 )
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
    {    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
        QStandardItem* item = new QStandardItem();         
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
        populateItem(*item,conversation);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
        appendRow(item);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
    else        
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
        // Update an existing item
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
        QModelIndex index = indexList[0];
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
        QStandardItem* item = this->item(index.row(), 0);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
        populateItem(*item,conversation);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
    }        
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
// ConversationsSummaryModel::deleteRow
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
void ConversationsSummaryModel::deleteRow(qint64 convId)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
    //match, if found remove item
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
    QModelIndexList indexList = this->match(index(0, 0), 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
            ConversationId, 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
            convId, 1, Qt::MatchExactly);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
    if( indexList.count() == 1 )
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
        QModelIndex index = indexList[0];
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
        this->removeRow(index.row());
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
        }        
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
// ConversationsSummaryModel::populateItem
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
void ConversationsSummaryModel::populateItem(QStandardItem& item, 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
        const CCsClientConversation& conversation)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
    {
34
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   209
    QCRITICAL_WRITE("ConversationsSummaryModel::populateItem start.");
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   210
            
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
    //get entry
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
    CCsConversationEntry* conEntry = conversation.GetConversationEntry(); 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
    //error scenario
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
    if(conEntry == NULL)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
        return;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
    // message details
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
    // conversation-id 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
    item.setData(conversation.GetConversationEntryId(), ConversationId);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
    // message-id
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
    item.setData(conEntry->EntryId(), ConvergedMsgId);	
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
    // send status
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
    item.setData(conEntry->GetSendState(),SendingState);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
    // direction
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
    item.setData(conEntry->ConversationDir(), Direction);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
    //msg-type
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
    int msgType = ConversationsEngineUtility::messageType(conEntry->GetType());
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
    item.setData(msgType, MessageType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
    //message sub-type   
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
    item.setData(ConversationsEngineUtility::messageSubType(conEntry->GetType()), MessageSubType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
    //handle BT messages, needs to be revisited again, once vcal/vcard over BT issue is fixed
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
    if(ConvergedMessage::BT == msgType)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
        handleBlueToothMessages(item, *conEntry);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
    else if(msgType == ConvergedMessage::BioMsg)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
        handleBioMessages(item, *conEntry);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
    else
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
    {       
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
        // description
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
        HBufC* body = conEntry->Description();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
        if( body && body->Length())
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
        {     
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   247
            QString bodytext(XQConversions::s60DescToQString(*body));
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
            item.setData(bodytext, BodyText); 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
            item.setData(bodytext, Subject );
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
    // time stamp
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
    TTime unixEpoch(KUnixEpoch);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
    TTimeIntervalSeconds seconds;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
    TTime timeStamp(conEntry->TimeStamp() );
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
    timeStamp.SecondsFrom(unixEpoch, seconds);       
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
    item.setData(seconds.Int(), TimeStamp); 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
    // unread count 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
    item.setData(conversation.GetUnreadMessageCount(), UnreadCount);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
    // contact details
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
    HBufC* disName = conversation.GetDisplayName(); 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
    QString displayName("");
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
    //display name
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
    if(disName && disName->Length())
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
        {
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   270
        displayName = XQConversions::s60DescToQString(*disName);
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
        item.setData(displayName,DisplayName); 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
    // contact number
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
    HBufC* contactno = conEntry->Contact();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    QString contactNumber("");
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
    if ( contactno && contactno->Length() )
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
        {
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   279
        contactNumber = XQConversions::s60DescToQString(*contactno);                  
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
        }        
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
    item.setData(contactNumber, ConversationAddress);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
    //set the contactId
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
    int contactId = conversation.GetContactId();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
    item.setData(contactId, ContactId);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
    // unread status        
34
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   288
    item.setData(conEntry->IsAttributeSet(ECsAttributeUnread),UnReadStatus); 
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   289
    
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   290
    QCRITICAL_WRITE("ConversationsSummaryModel::populateItem start.");
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
// ConversationsModel::handleBlueToothMessages
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
void ConversationsSummaryModel::handleBlueToothMessages(QStandardItem& item,
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
    const CCsConversationEntry& entry)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
{
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
    //TODO, needs to be revisited again, once BT team provides the solution for
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
    //BT received as Biomsg issue.
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   303
    QString description = XQConversions::s60DescToQString(*(entry.Description()));
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
    if (description.contains(".vcf") || description.contains(".ics")) // "vCard"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
        //message sub-type
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
        item.setData(ConvergedMessage::VCard, MessageSubType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
        //parse vcf file to get the details
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
        QString displayName = MsgContactHandler::getVCardDisplayName(
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
                description);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
        item.setData(displayName, BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
    else 
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
    {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
        if (description.contains(".vcs")) // "vCalendar"
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
            //message sub-type
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
            item.setData(ConvergedMessage::VCal, MessageSubType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
        else
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
        {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
            //message sub-type
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
            item.setData(ConvergedMessage::None, MessageSubType);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
        //for BT messages we show filenames for all other (except vcard) messages
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
        //get filename and set as body
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
        QFileInfo fileinfo(description);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
        QString filename = fileinfo.fileName();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
        item.setData(filename, BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
}
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
// ConversationsSummaryModel::handleBioMessages
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
// @see header
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
//---------------------------------------------------------------
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
void ConversationsSummaryModel::handleBioMessages(QStandardItem& item, const CCsConversationEntry& entry)
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
{
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
    UniDataModelLoader* pluginLoader = new UniDataModelLoader;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
    UniDataModelPluginInterface* bioMsgPlugin = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
    bioMsgPlugin->setMessageId(entry.EntryId());
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
    int msgSubType = ConversationsEngineUtility::messageSubType(entry.GetType());
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
    if (ConvergedMessage::VCard == msgSubType) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
        if (bioMsgPlugin->attachmentCount() > 0) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
            UniMessageInfoList attList = bioMsgPlugin->attachmentList();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
            QString attachmentPath = attList[0]->path();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
            //get display-name and set as bodytext
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
            QString displayName = MsgContactHandler::getVCardDisplayName(
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
                    attachmentPath);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
            item.setData(displayName, BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
            // clear attachement list : its allocated at data model
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
            while (!attList.isEmpty()) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
                delete attList.takeFirst();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
            }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
    else if (ConvergedMessage::VCal == msgSubType) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
        //not supported
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
    else if (ConvergedMessage::RingingTone == msgSubType) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
        if (bioMsgPlugin->attachmentCount() > 0) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
            UniMessageInfoList attList = bioMsgPlugin->attachmentList();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
            QString attachmentPath = attList[0]->path();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
            	
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
            //get tone title, and set as bodytext
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
            RingBc ringBc;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
            item.setData(ringBc.toneTitle(attachmentPath), BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
            while (!attList.isEmpty()) {
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
                delete attList.takeFirst();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
            }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
    }
34
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   378
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   379
   else if(ConvergedMessage::NokiaService == msgSubType){
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   380
        // This is a bio message so lets parse it and see if it has a associated attachment ..        
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   381
        if (bioMsgPlugin->attachmentCount() > 0) {
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   382
				// TODO : need to confirm if we need to read from attachment
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   383
        }
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   384
        else {// description
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   385
            HBufC* description = entry.Description();
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   386
            QString subject("");
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   387
            if (description && description->Length()) {
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   388
                subject = (XQConversions::s60DescToQString(*description));
34
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   389
                item.setData(subject, BodyText);
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   390
            }
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   391
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   392
        }
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   393
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   394
    }
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   395
84197e66a4bd Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   396
   else {
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
        // description
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
        HBufC* description = entry.Description();
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
        QString subject("");
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
        if (description && description->Length()) {
43
35b64624a9e7 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 34
diff changeset
   401
            subject = (XQConversions::s60DescToQString(*description));
31
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
            item.setData(subject, BodyText);
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
        }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
    }
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
    
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
    delete pluginLoader;
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
}
ebfee66fde93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
// EOF