author | hgs |
Fri, 09 Jul 2010 14:46:10 +0530 | |
changeset 41 | 25fe1fe642e3 |
parent 38 | 4e4b6adb1024 |
child 46 | b1f0785c289d |
permissions | -rw-r--r-- |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "conversationsmodel.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include "conversationsenginedefines.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include "conversationmsgstorehandler.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "convergedmessage.h" |
37 | 22 |
#include <xqconversions.h> |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "conversationsengineutility.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include "unidatamodelloader.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include "unidatamodelplugininterface.h" |
37 | 26 |
#include "ringbc.h" |
27 |
#include "msgcontacthandler.h" |
|
28 |
#include "mmsconformancecheck.h" |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include <ccsconversationentry.h> |
37 | 30 |
#include <fileprotectionresolver.h> |
31 |
||
32 |
#include "debugtraces.h" |
|
33 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
#include <QFile> |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
35 |
#include <QFileInfo> |
37 | 36 |
#include <s32mem.h> |
37 |
#include <s32strm.h> |
|
38 |
#include <fbs.h> |
|
39 |
#include <ccsdefs.h> |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
|
37 | 41 |
//CONSTANTS |
42 |
_LIT(KDbFileName, "c:[2002A542]conversations.db"); |
|
43 |
||
44 |
// preview sql query |
|
45 |
_LIT(KSelectConvMsgsStmt, "SELECT message_id, msg_processingstate, subject, body_text, preview_path, msg_property, preview_icon FROM conversation_messages WHERE message_id=:message_id "); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
|
37 | 47 |
//selecet preview-icon query |
48 |
_LIT(KSelectPreviewIconStmt,"SELECT message_id, preview_icon FROM conversation_messages WHERE message_id = :message_id "); |
|
49 |
||
50 |
// preview-cache max cost (items) |
|
51 |
const int CACHE_COST = 50; |
|
52 |
//Preview thumbnail size |
|
53 |
const int KWidth = 9.5 * 6.7; |
|
54 |
const int KHeight = 9.5 * 6.7; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
// ConversationsModel::ConversationsModel |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
// Constructor |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
//--------------------------------------------------------------- |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
59 |
ConversationsModel::ConversationsModel(ConversationMsgStoreHandler* msgStoreHandler, |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
60 |
QObject* parent) : |
37 | 61 |
QStandardItemModel(parent), mMsgStoreHandler(msgStoreHandler), iSqlDbOpen(EFalse) |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
62 |
{ |
37 | 63 |
//Open SQL DB |
64 |
if (KErrNone == iSqlDb.Open(KDbFileName)) |
|
65 |
{ |
|
66 |
iSqlDbOpen = ETrue; |
|
67 |
} |
|
68 |
previewIconCache.setMaxCost(CACHE_COST); |
|
69 |
||
70 |
int err = connect(this, SIGNAL(retrievePreviewIcon(int, QString&)), this, |
|
71 |
SLOT(updatePreviewIcon(int, QString&))); |
|
72 |
QCRITICAL_WRITE_FORMAT("Error from connect()", err) |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
73 |
iDataModelPluginLoader = new UniDataModelLoader; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
74 |
iMmsDataPlugin = iDataModelPluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
75 |
iBioMsgPlugin = iDataModelPluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
76 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
// ConversationsModel::~ConversationsModel |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
// Destructor |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
ConversationsModel::~ConversationsModel() |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
83 |
{ |
37 | 84 |
//Close SQL-DB |
85 |
iSqlDb.Close(); |
|
86 |
||
87 |
//clear preview-cache |
|
88 |
previewIconCache.clear(); |
|
89 |
||
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
90 |
if (iDataModelPluginLoader) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
delete iDataModelPluginLoader; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
iDataModelPluginLoader = NULL; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
94 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
// ConversationsModel::data |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
// @see header |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
//--------------------------------------------------------------- |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
100 |
QVariant ConversationsModel::data(const QModelIndex & index, int role) const |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
QVariant value; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
QStandardItem* item = itemFromIndex(index); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
104 |
switch (role) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
105 |
case ConversationId: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
106 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
107 |
value = item->data(ConversationId); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
108 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
109 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
110 |
case UnReadStatus: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
111 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
112 |
value = item->data(UnReadStatus); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
113 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
114 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
115 |
case ContactId: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
116 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
117 |
value = item->data(ContactId); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
118 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
119 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
120 |
case TimeStamp: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
121 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
122 |
value = item->data(TimeStamp); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
123 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
124 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
125 |
case ConvergedMsgId: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
126 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
127 |
value = item->data(ConvergedMsgId); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
128 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
129 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
130 |
case MessageProperty: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
131 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
132 |
value = item->data(MessageProperty); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
133 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
134 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
135 |
case MessageType: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
136 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
137 |
value = item->data(MessageType); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
138 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
139 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
140 |
case MessageSubType: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
141 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
142 |
value = item->data(MessageSubType); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
143 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
144 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
145 |
case Subject: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
146 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
147 |
value = item->data(Subject); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
148 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
149 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
150 |
case BodyText: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
151 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
152 |
value = item->data(BodyText); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
153 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
154 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
155 |
case ConversationAddress: |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
{ |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
157 |
value = item->data(ConversationAddress); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
158 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
159 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
160 |
case Direction: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
161 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
162 |
value = item->data(Direction); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
163 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
164 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
165 |
case SendingState: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
166 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
167 |
value = item->data(SendingState); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
168 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
169 |
} |
37 | 170 |
case PreviewIcon: |
171 |
{ |
|
172 |
QString filepath(item->data(Attachments).toString()); |
|
173 |
int msgId = item->data(ConvergedMsgId).toInt(); |
|
174 |
HbIcon *icon = getPreviewIconItem(msgId, filepath); |
|
175 |
return *icon; |
|
176 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
177 |
case MessagePriority: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
178 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
179 |
value = item->data(MessagePriority); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
180 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
181 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
182 |
case Attachments: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
183 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
184 |
value = item->data(Attachments); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
185 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
186 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
187 |
case MessageLocation: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
188 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
189 |
value = item->data(MessageLocation); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
190 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
191 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
192 |
case MessageStore: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
193 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
194 |
value = item->data(MessageStore); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
195 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
196 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
197 |
case ConversationAlias: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
198 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
199 |
value = item->data(ConversationAlias); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
200 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
201 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
202 |
case UnreadCount: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
203 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
204 |
value = item->data(UnreadCount); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
205 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
206 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
207 |
case DisplayName: // Fall through start |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
208 |
value = item->data(DisplayName); |
37 | 209 |
break; |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
210 |
case Avatar: // Fall througn end |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
211 |
value = item->data(Avatar); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
212 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
213 |
case NotificationStatus: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
214 |
value = item->data(NotificationStatus); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
215 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
216 |
default: |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
217 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
218 |
//No matching role found, set invalid variant |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
219 |
value = QVariant(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
220 |
break; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
221 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
222 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
223 |
return value; |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
224 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
225 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
// ConversationsModel::addRow |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
228 |
// @see header |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
229 |
//--------------------------------------------------------------- |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
230 |
void ConversationsModel::addRow(const CCsConversationEntry& entry, bool dynamicUpdate) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
{ |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
232 |
int msgId = entry.EntryId(); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
//match, if found update else add item |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
234 |
QModelIndexList indexList = this->match(index(0, 0), ConvergedMsgId, msgId, -1, |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
235 |
Qt::MatchExactly); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
236 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
// if not found, add new item |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
238 |
if (indexList.count() == 0) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
QStandardItem* item = new QStandardItem(); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
240 |
populateItem(*item, entry); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
241 |
if (!dynamicUpdate) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
242 |
insertRow(0, item); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
244 |
else { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
245 |
int i; |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
246 |
for (i = rowCount() - 1; i >= 0; --i) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
247 |
QStandardItem* modelItem = this->item(i, 0); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
248 |
if (modelItem->data(ConvergedMsgId).toInt() < item->data(ConvergedMsgId).toInt()) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
249 |
if (i == rowCount() - 1) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
appendRow(item); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
252 |
else { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
253 |
insertRow(i + 1, item); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
return; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
258 |
if (i == 0) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
259 |
insertRow(0, item); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
260 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
262 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
263 |
else { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
// Update an existing item |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
QModelIndex index = indexList[0]; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
QStandardItem* item = this->item(index.row(), 0); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
267 |
populateItem(*item, entry); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
268 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
270 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
271 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
272 |
// ConversationsModel::deleteRow |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
273 |
// @see header |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
275 |
void ConversationsModel::deleteRow(int msgId) |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
276 |
{ |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
277 |
//match, if found remove item |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
278 |
QModelIndexList indexList = |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
279 |
this->match(index(0, 0), ConvergedMsgId, msgId, 1, Qt::MatchExactly); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
281 |
if (indexList.count() == 1) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
QModelIndex index = indexList[0]; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
283 |
this->removeRow(index.row()); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
284 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
285 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
286 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
287 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
288 |
// ConversationsModel::populateItem |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
289 |
// @see header |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
290 |
//--------------------------------------------------------------- |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
291 |
void ConversationsModel::populateItem(QStandardItem& item, const CCsConversationEntry& entry) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
292 |
{ |
37 | 293 |
QCRITICAL_WRITE("ConversationsModel::populateItem start."); |
294 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
295 |
int msgId = entry.EntryId(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
296 |
// id |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
297 |
item.setData(msgId, ConvergedMsgId); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
298 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
299 |
// description |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
HBufC* description = entry.Description(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
301 |
QString subject(""); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
302 |
if (description && description->Length()) { |
37 | 303 |
subject = (XQConversions::s60DescToQString(*description)); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
304 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
305 |
|
37 | 306 |
// time stamp |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
307 |
TTime unixEpoch(KUnixEpoch); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
308 |
TTimeIntervalSeconds seconds; |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
309 |
TTime timeStamp(entry.TimeStamp()); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
timeStamp.SecondsFrom(unixEpoch, seconds); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
item.setData(seconds.Int(), TimeStamp); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
313 |
//contact details |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
HBufC* contact = entry.Contact(); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
315 |
if (contact && contact->Length()) { |
37 | 316 |
item.setData(XQConversions::s60DescToQString(*contact), ConversationAddress); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
317 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
// message type. |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
320 |
int msgType = ConversationsEngineUtility::messageType(entry.GetType()); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
321 |
item.setData(msgType, MessageType); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
322 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
323 |
//message sub-type |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
324 |
item.setData(ConversationsEngineUtility::messageSubType(entry.GetType()), MessageSubType); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
325 |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
// unread status |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
327 |
if (entry.IsAttributeSet(ECsAttributeUnread)) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
328 |
item.setData(true, UnReadStatus); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
329 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
330 |
else { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
331 |
item.setData(false, UnReadStatus); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
333 |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
//sending state |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
335 |
item.setData(entry.GetSendState(), SendingState); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
336 |
// direction |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
337 |
item.setData(entry.ConversationDir(), Direction); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
//location |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
340 |
if (entry.ConversationDir() == ECsDirectionIncoming) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
item.setData(ConvergedMessage::Inbox, MessageLocation); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
342 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
343 |
else if (entry.IsAttributeSet(ECsAttributeDraft)) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
344 |
item.setData(ConvergedMessage::Draft, MessageLocation); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
345 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
346 |
else if (entry.IsAttributeSet(ECsAttributeSent)) { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
item.setData(ConvergedMessage::Sent, MessageLocation); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
349 |
else { |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
item.setData(ConvergedMessage::Outbox, MessageLocation); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
351 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
|
37 | 353 |
//message specific handling |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
354 |
if (msgType == ConvergedMessage::Mms) { |
37 | 355 |
QCRITICAL_WRITE("ConversationsModel::populateItem MMS start.") |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
356 |
handleMMS(item, entry); |
37 | 357 |
QCRITICAL_WRITE("ConversationsModel::populateItem MMS end.") |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
358 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
359 |
else if(msgType == ConvergedMessage::MmsNotification) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
360 |
item.setData(subject, Subject); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
361 |
handleMMSNotification(item, entry); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
362 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
363 |
else if (msgType == ConvergedMessage::BT) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
364 |
handleBlueToothMessages(item, entry); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
365 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
366 |
else if (msgType == ConvergedMessage::BioMsg) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
367 |
handleBioMessages(item, entry); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
368 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
369 |
else { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
370 |
// sms bodytext |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
371 |
item.setData(subject, BodyText); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
372 |
} |
37 | 373 |
|
374 |
QCRITICAL_WRITE("ConversationsModel::populateItem end."); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
375 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
376 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
377 |
//--------------------------------------------------------------- |
37 | 378 |
// ConversationsModel::validateMsgForForward |
379 |
// @see header file |
|
380 |
//--------------------------------------------------------------- |
|
381 |
bool ConversationsModel::validateMsgForForward(qint32 messageId) |
|
382 |
{ |
|
383 |
bool retValue = true; |
|
384 |
//Validate if the mms msg can be forwarded or not |
|
385 |
MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |
|
386 |
retValue = mmsConformanceCheck->validateMsgForForward(messageId); |
|
387 |
||
388 |
delete mmsConformanceCheck; |
|
389 |
return retValue; |
|
390 |
} |
|
391 |
||
392 |
||
393 |
//--------------------------------------------------------------- |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
394 |
// ConversationsModel::handleMMS |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
395 |
// @see header |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
396 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
397 |
void ConversationsModel::handleMMS(QStandardItem& item, const CCsConversationEntry& entry) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
398 |
{ |
37 | 399 |
//msg_id |
400 |
int msgId = entry.EntryId(); |
|
401 |
||
402 |
bool isEntryInDb = false; |
|
403 |
TInt err = KErrNone; |
|
404 |
||
405 |
//check if db is open and query db |
|
406 |
if (iSqlDbOpen) |
|
407 |
{ |
|
408 |
RSqlStatement sqlSelectStmt; |
|
409 |
err = sqlSelectStmt.Prepare(iSqlDb, KSelectConvMsgsStmt); |
|
410 |
||
411 |
// move to fallback option |
|
412 |
if (KErrNone == err) |
|
413 |
{ |
|
414 |
TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); |
|
415 |
TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex(_L("msg_processingstate")); |
|
416 |
TInt subjectIndex = sqlSelectStmt.ColumnIndex(_L("subject")); |
|
417 |
TInt bodyIndex = sqlSelectStmt.ColumnIndex(_L("body_text")); |
|
418 |
TInt previewPathIndex = sqlSelectStmt.ColumnIndex( |
|
419 |
_L("preview_path")); |
|
420 |
TInt msgpropertyIndex = sqlSelectStmt.ColumnIndex( |
|
421 |
_L("msg_property")); |
|
422 |
TInt previewIconIndex = sqlSelectStmt.ColumnIndex( |
|
423 |
_L("preview_icon")); |
|
424 |
||
425 |
err = sqlSelectStmt.BindInt(msgIdIndex, msgId); |
|
426 |
||
427 |
// populate item |
|
428 |
if ((KErrNone == err) && (sqlSelectStmt.Next() == KSqlAtRow)) |
|
429 |
{ |
|
430 |
int msgProcessingState = 0; |
|
431 |
msgProcessingState = sqlSelectStmt.ColumnInt( |
|
432 |
msgProcessingStateIndex); |
|
433 |
if (msgProcessingState == EPreviewMsgProcessed) |
|
434 |
{ |
|
435 |
// use entry to populate model only when, |
|
436 |
// entry is present in DB and its processing is over. |
|
437 |
RBuf subjectBuffer; |
|
438 |
subjectBuffer.Create(sqlSelectStmt.ColumnSize( |
|
439 |
subjectIndex)); |
|
440 |
sqlSelectStmt.ColumnText(subjectIndex, subjectBuffer); |
|
441 |
||
442 |
item.setData(XQConversions::s60DescToQString( |
|
443 |
subjectBuffer), Subject); |
|
444 |
subjectBuffer.Close(); |
|
445 |
||
446 |
RBuf bodyBuffer; |
|
447 |
bodyBuffer.Create(sqlSelectStmt.ColumnSize(bodyIndex)); |
|
448 |
sqlSelectStmt.ColumnText(bodyIndex, bodyBuffer); |
|
449 |
||
450 |
item.setData( |
|
451 |
XQConversions::s60DescToQString(bodyBuffer), |
|
452 |
BodyText); |
|
453 |
bodyBuffer.Close(); |
|
454 |
||
455 |
RBuf previewPathBuffer; |
|
456 |
previewPathBuffer.Create(sqlSelectStmt.ColumnSize( |
|
457 |
previewPathIndex)); |
|
458 |
sqlSelectStmt.ColumnText(previewPathIndex, |
|
459 |
previewPathBuffer); |
|
460 |
||
461 |
//Rightnow set inside attachments |
|
462 |
QString attachmentPath(XQConversions::s60DescToQString( |
|
463 |
previewPathBuffer)); |
|
464 |
||
465 |
item.setData(attachmentPath, Attachments); |
|
466 |
previewPathBuffer.Close(); |
|
467 |
||
468 |
int msgProperty = 0; |
|
469 |
msgProperty = sqlSelectStmt.ColumnInt(msgpropertyIndex); |
|
470 |
item.setData(msgProperty, MessageProperty); |
|
471 |
||
472 |
RSqlColumnReadStream stream; |
|
473 |
//Get data from binary column BLOB |
|
474 |
TInt err = stream.ColumnBinary(sqlSelectStmt, |
|
475 |
previewIconIndex); |
|
476 |
||
477 |
QCRITICAL_WRITE_FORMAT("Error from ColumnBinary()", err) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
|
37 | 479 |
if (err == KErrNone) |
480 |
{ |
|
481 |
CFbsBitmap *bitmap = new CFbsBitmap; |
|
482 |
TRAPD(err,bitmap->InternalizeL(stream)); |
|
483 |
QCRITICAL_WRITE_FORMAT("Error from bitmap InternalizeL()", err) |
|
484 |
||
485 |
//convert bitmap to pixmap |
|
486 |
if (err == KErrNone) |
|
487 |
{ |
|
488 |
TSize size = bitmap->SizeInPixels(); |
|
489 |
int bytesPerLine = bitmap->ScanLineLength( |
|
490 |
size.iWidth, bitmap->DisplayMode()); |
|
491 |
const uchar* dataPtr = |
|
492 |
(const uchar*) bitmap->DataAddress(); |
|
493 |
||
494 |
QPixmap pixmap = QPixmap::fromImage(QImage( |
|
495 |
dataPtr, size.iWidth, size.iHeight, |
|
496 |
bytesPerLine, QImage::Format_RGB16)); |
|
497 |
||
498 |
setPreviewIcon(pixmap, attachmentPath, msgId, |
|
499 |
true); |
|
500 |
||
501 |
} |
|
502 |
//remove bitmap |
|
503 |
delete bitmap; |
|
504 |
} |
|
505 |
||
506 |
//set flag to disable fallback option |
|
507 |
isEntryInDb = true; |
|
508 |
} |
|
509 |
} |
|
510 |
} |
|
511 |
sqlSelectStmt.Close(); |
|
512 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
513 |
|
37 | 514 |
//fallback option incase of db operation failure or enry not found in DB |
515 |
//populate from data plugins |
|
516 |
if (!isEntryInDb || err != KErrNone) |
|
517 |
{ |
|
38 | 518 |
int error = iMmsDataPlugin->setMessageId(entry.EntryId()); |
519 |
if(error != KErrNone) |
|
37 | 520 |
{ |
521 |
// skip all |
|
522 |
return; |
|
523 |
} |
|
524 |
int msgProperty = 0; |
|
525 |
||
526 |
if (iMmsDataPlugin->attachmentCount() > 0) |
|
527 |
{ |
|
528 |
msgProperty |= EPreviewAttachment; |
|
529 |
} |
|
530 |
||
531 |
if(validateMsgForForward(entry.EntryId())) |
|
532 |
{ |
|
533 |
msgProperty |= EPreviewForward; |
|
534 |
} |
|
535 |
||
536 |
//subject |
|
537 |
item.setData(iMmsDataPlugin->subject(), Subject); |
|
538 |
||
539 |
int slideCount = iMmsDataPlugin->slideCount(); |
|
540 |
bool isBodyTextSet = false; |
|
541 |
bool isAudioSet = false; |
|
542 |
bool isImageSet = false; |
|
543 |
bool isVideoSet = false; |
|
544 |
QString textContent; |
|
545 |
QString videoPath; |
|
546 |
QString imagePath; |
|
547 |
||
548 |
for (int i = 0; i < slideCount; ++i) |
|
549 |
{ |
|
550 |
UniMessageInfoList objectList = iMmsDataPlugin->slideContent(i); |
|
551 |
for (int index = 0; index < objectList.count(); ++index) |
|
552 |
{ |
|
553 |
if (!isBodyTextSet && objectList[index]->mimetype().contains( |
|
554 |
"text")) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
555 |
{ |
37 | 556 |
QFile file(objectList[index]->path()); |
557 |
file.open(QIODevice::ReadOnly); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
558 |
textContent = file.readAll(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
559 |
item.setData(textContent, BodyText); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
560 |
isBodyTextSet = true; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
561 |
file.close(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
562 |
} |
37 | 563 |
if (!isVideoSet && !isImageSet && objectList[index]->mimetype().contains( |
564 |
"image")) |
|
565 |
{ |
|
566 |
isImageSet = true; |
|
567 |
msgProperty |= EPreviewImage; |
|
568 |
if (objectList[index]->isProtected()) |
|
569 |
{ |
|
570 |
msgProperty |= EPreviewProtectedImage; |
|
571 |
} |
|
572 |
if (objectList[index]->isCorrupted()) |
|
573 |
{ |
|
574 |
msgProperty |= EPreviewCorruptedImage; |
|
575 |
} |
|
576 |
imagePath = objectList[index]->path(); |
|
577 |
} |
|
578 |
if (!isVideoSet && !isAudioSet && objectList[index]->mimetype().contains( |
|
579 |
"audio")) |
|
580 |
{ |
|
581 |
msgProperty |= EPreviewAudio; |
|
582 |
if (objectList[index]->isProtected()) |
|
583 |
{ |
|
584 |
msgProperty |= EPreviewProtectedAudio; |
|
585 |
} |
|
586 |
if (objectList[index]->isCorrupted()) |
|
587 |
{ |
|
588 |
msgProperty |= EPreviewCorruptedAudio; |
|
589 |
} |
|
590 |
isAudioSet = true; |
|
591 |
} |
|
592 |
if (!( isImageSet || isAudioSet) && !isVideoSet && objectList[index]->mimetype().contains( |
|
593 |
"video")) |
|
594 |
{ |
|
595 |
isVideoSet = true; |
|
596 |
msgProperty |= EPreviewVideo; |
|
597 |
if (objectList[index]->isProtected()) |
|
598 |
{ |
|
599 |
msgProperty |= EPreviewProtectedVideo; |
|
600 |
} |
|
601 |
if (objectList[index]->isCorrupted()) |
|
602 |
{ |
|
603 |
msgProperty |= EPreviewCorruptedVideo; |
|
604 |
} |
|
605 |
videoPath = objectList[index]->path(); |
|
606 |
} |
|
607 |
} |
|
608 |
foreach(UniMessageInfo* slide,objectList) |
|
609 |
{ |
|
610 |
delete slide; |
|
611 |
} |
|
612 |
} |
|
613 |
QPixmap pixmap; |
|
614 |
//populate item with the attachment list |
|
615 |
//TODO: This code is not required bcoz video icon is show and not preview |
|
616 |
if (isVideoSet) |
|
617 |
{ |
|
618 |
item.setData(videoPath, Attachments); |
|
619 |
// Store thumbnail only for non protected, non corrupted content. |
|
620 |
if (!(EPreviewProtectedVideo & msgProperty) && |
|
621 |
!(EPreviewCorruptedVideo & msgProperty)) |
|
622 |
{ |
|
623 |
setPreviewIcon(pixmap, videoPath, msgId, false); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
624 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
625 |
} |
37 | 626 |
else if (isImageSet) |
627 |
{ |
|
628 |
item.setData(imagePath, Attachments); |
|
629 |
// Store thumbnail only for non protected, non corrupted content. |
|
630 |
if (!(EPreviewProtectedImage & msgProperty) && |
|
631 |
!(EPreviewCorruptedImage & msgProperty)) |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
632 |
{ |
37 | 633 |
setPreviewIcon(pixmap, imagePath, msgId, false); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
634 |
} |
37 | 635 |
} |
636 |
//populate msgProperty |
|
637 |
item.setData(msgProperty, MessageProperty); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
638 |
} |
37 | 639 |
|
640 |
// fill other attributes |
|
641 |
if (entry.IsAttributeSet(ECsAttributeHighPriority)) |
|
642 |
{ |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
643 |
item.setData(ConvergedMessage::High, MessagePriority); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
644 |
} |
37 | 645 |
else if (entry.IsAttributeSet(ECsAttributeLowPriority)) |
646 |
{ |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
647 |
item.setData(ConvergedMessage::Low, MessagePriority); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
648 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
649 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
650 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
651 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
652 |
// ConversationsModel::handleMMSNotification |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
653 |
// @see header |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
654 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
655 |
void ConversationsModel::handleMMSNotification(QStandardItem& item, |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
656 |
const CCsConversationEntry& entry) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
657 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
658 |
// set context to current entry |
37 | 659 |
TRAPD(err, mMsgStoreHandler->setNotificationMessageIdL(entry.EntryId())); |
660 |
if(err != KErrNone) |
|
661 |
{ |
|
662 |
return; |
|
663 |
} |
|
664 |
||
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
665 |
// fetch relevent info to show in CV |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
666 |
// notification state e.g. waiting, retrieving etc |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
667 |
QString statusStr; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
668 |
int status; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
669 |
mMsgStoreHandler->NotificationStatus(status, statusStr); |
37 | 670 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
671 |
// create data for bodytext role |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
672 |
QString dataText; |
41 | 673 |
dataText.append(mMsgStoreHandler->NotificationMsgSize()); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
674 |
dataText.append(QChar::LineSeparator); |
41 | 675 |
dataText.append(mMsgStoreHandler->NotificationClass()); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
676 |
dataText.append(QChar::LineSeparator); |
41 | 677 |
dataText.append(mMsgStoreHandler->NotificationExpiryDate()); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
678 |
if(!statusStr.isEmpty()) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
679 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
680 |
dataText.append(QChar::LineSeparator); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
681 |
dataText.append(statusStr); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
682 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
683 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
684 |
// set fetched data to roles |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
685 |
item.setData(status, NotificationStatus); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
686 |
item.setData(dataText, BodyText); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
687 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
688 |
if (entry.IsAttributeSet(ECsAttributeHighPriority)) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
689 |
item.setData(ConvergedMessage::High, MessagePriority); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
690 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
691 |
else if (entry.IsAttributeSet(ECsAttributeLowPriority)) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
692 |
item.setData(ConvergedMessage::Low, MessagePriority); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
693 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
694 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
695 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
696 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
697 |
// ConversationsModel::handleBlueToothMessages |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
698 |
// @see header |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
699 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
700 |
void ConversationsModel::handleBlueToothMessages(QStandardItem& item, |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
701 |
const CCsConversationEntry& entry) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
702 |
{ |
41 | 703 |
int msgSubType = ConversationsEngineUtility::messageSubType(entry.GetType()); |
704 |
if (msgSubType == ConvergedMessage::VCard) |
|
705 |
{ |
|
706 |
iBioMsgPlugin->setMessageId(entry.EntryId()); |
|
707 |
||
708 |
if (iBioMsgPlugin->attachmentCount() > 0) |
|
709 |
{ |
|
710 |
UniMessageInfoList attList = iBioMsgPlugin->attachmentList(); |
|
711 |
QString attachmentPath = attList[0]->path(); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
712 |
|
41 | 713 |
//get display-name and set as bodytext |
714 |
QString displayName = MsgContactHandler::getVCardDisplayName(attachmentPath); |
|
715 |
item.setData(displayName, BodyText); |
|
716 |
// clear attachement list : its allocated at data model |
|
717 |
while (!attList.isEmpty()) |
|
718 |
{ |
|
719 |
delete attList.takeFirst(); |
|
720 |
} |
|
721 |
||
722 |
} |
|
723 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
724 |
|
41 | 725 |
else |
726 |
{ |
|
727 |
QString description = XQConversions::s60DescToQString(*(entry.Description())); |
|
728 |
||
729 |
if (msgSubType == ConvergedMessage::VCal) // "vCalendar" |
|
730 |
{ |
|
731 |
//message sub-type |
|
732 |
item.setData(ConvergedMessage::VCal, MessageSubType); |
|
733 |
} |
|
734 |
else |
|
735 |
{ |
|
736 |
//message sub-type |
|
737 |
item.setData(ConvergedMessage::None, MessageSubType); |
|
738 |
} |
|
739 |
//for BT messages we show filenames for all other (except vcard) messages |
|
740 |
//get filename and set as body |
|
741 |
QFileInfo fileinfo(description); |
|
742 |
QString filename = fileinfo.fileName(); |
|
743 |
item.setData(filename, BodyText); |
|
744 |
} |
|
745 |
||
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
746 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
747 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
748 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
749 |
// ConversationsModel::handleBioMessages |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
750 |
// @see header |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
751 |
//--------------------------------------------------------------- |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
752 |
void ConversationsModel::handleBioMessages(QStandardItem& item, const CCsConversationEntry& entry) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
753 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
754 |
iBioMsgPlugin->setMessageId(entry.EntryId()); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
755 |
int msgSubType = ConversationsEngineUtility::messageSubType(entry.GetType()); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
756 |
if (ConvergedMessage::VCard == msgSubType) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
757 |
if (iBioMsgPlugin->attachmentCount() > 0) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
758 |
UniMessageInfoList attList = iBioMsgPlugin->attachmentList(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
759 |
QString attachmentPath = attList[0]->path(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
760 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
761 |
//get display-name and set as bodytext |
37 | 762 |
QString displayName = |
763 |
MsgContactHandler::getVCardDisplayName( |
|
764 |
attachmentPath); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
765 |
item.setData(displayName, BodyText); |
37 | 766 |
item.setData(attachmentPath, Attachments); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
767 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
768 |
// clear attachement list : its allocated at data model |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
769 |
while (!attList.isEmpty()) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
770 |
delete attList.takeFirst(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
771 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
772 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
773 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
774 |
else if (ConvergedMessage::VCal == msgSubType) { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
775 |
//not supported |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
776 |
} |
37 | 777 |
else if (ConvergedMessage::RingingTone == msgSubType) { |
778 |
if (iBioMsgPlugin->attachmentCount() > 0) { |
|
779 |
UniMessageInfoList attList = iBioMsgPlugin->attachmentList(); |
|
780 |
QString attachmentPath = attList[0]->path(); |
|
781 |
||
782 |
//get tone title, and set as bodytext |
|
783 |
RingBc ringBc; |
|
784 |
item.setData(ringBc.toneTitle(attachmentPath), BodyText); |
|
785 |
while (!attList.isEmpty()) { |
|
786 |
delete attList.takeFirst(); |
|
787 |
} |
|
788 |
} |
|
789 |
||
790 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
791 |
else { |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
792 |
// description |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
793 |
HBufC* description = entry.Description(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
794 |
QString subject(""); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
795 |
if (description && description->Length()) { |
37 | 796 |
subject = (XQConversions::s60DescToQString(*description)); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
797 |
item.setData(subject, BodyText); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
798 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
799 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
800 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
801 |
|
37 | 802 |
//--------------------------------------------------------------- |
803 |
// ConversationsModel::getDBHandle() |
|
804 |
// @see header |
|
805 |
//--------------------------------------------------------------- |
|
806 |
RSqlDatabase& ConversationsModel::getDBHandle(TBool& isOpen) |
|
807 |
{ |
|
808 |
isOpen = iSqlDbOpen; |
|
809 |
return iSqlDb; |
|
810 |
} |
|
811 |
||
812 |
//--------------------------------------------------------------- |
|
813 |
// ConversationsModel::setPreviewIcon() |
|
814 |
// @see header |
|
815 |
//--------------------------------------------------------------- |
|
816 |
void ConversationsModel::setPreviewIcon(QPixmap& pixmap, QString& filePath, |
|
817 |
int msgId, bool inDb) |
|
818 |
{ |
|
819 |
||
820 |
//Since the population happens in reverse this check is needed so that |
|
821 |
//most recent items have their icons present in cache |
|
822 |
if (previewIconCache.totalCost() >= previewIconCache.maxCost()) |
|
823 |
return; |
|
824 |
||
825 |
// if not found in db, set from file path |
|
826 |
if (!inDb) |
|
827 |
{ |
|
828 |
QPixmap pixmap(filePath); |
|
829 |
QPixmap scaledPixmap = pixmap.scaled(KWidth, KHeight, Qt::IgnoreAspectRatio); |
|
830 |
HbIcon *previewIcon = new HbIcon(scaledPixmap); |
|
831 |
||
832 |
previewIconCache.insert(msgId, previewIcon); |
|
833 |
||
834 |
} |
|
835 |
else |
|
836 |
{ |
|
837 |
HbIcon *previewIcon = new HbIcon(pixmap); |
|
838 |
previewIconCache.insert(msgId, previewIcon); |
|
839 |
} |
|
840 |
} |
|
841 |
||
842 |
//--------------------------------------------------------------- |
|
843 |
// ConversationsModel::getPreviewIconItem() |
|
844 |
// @see header |
|
845 |
//--------------------------------------------------------------- |
|
846 |
HbIcon* ConversationsModel::getPreviewIconItem(int msgId, |
|
847 |
QString& filepath) const |
|
848 |
{ |
|
849 |
QCRITICAL_WRITE("ConversationsModel::getPreviewIconItem start.") |
|
850 |
||
851 |
//Initialize icon from the Cache will be NULL if Item not present |
|
852 |
HbIcon* previewIcon = previewIconCache[msgId]; |
|
853 |
if (!previewIcon) |
|
854 |
{ |
|
855 |
//This is done in this way as non-const function call cant be done here |
|
856 |
emit retrievePreviewIcon(msgId, filepath); |
|
857 |
||
858 |
previewIcon = previewIconCache[msgId]; |
|
859 |
} |
|
860 |
||
861 |
QCRITICAL_WRITE("ConversationsModel::getPreviewIconItem start.") |
|
862 |
||
863 |
return previewIcon; |
|
864 |
} |
|
865 |
||
866 |
//--------------------------------------------------------------- |
|
867 |
// ConversationsModel::updatePreviewIcon() |
|
868 |
// @see header |
|
869 |
//--------------------------------------------------------------- |
|
870 |
void ConversationsModel::updatePreviewIcon(int msgId, QString& filePath) |
|
871 |
{ |
|
872 |
QCRITICAL_WRITE("ConversationsModel::updatePreviewIcon start.") |
|
873 |
||
874 |
//sql query to get preview-icon from DB |
|
875 |
bool imagePreviewed = false; |
|
876 |
QPixmap pixmap; |
|
877 |
||
878 |
if (iSqlDbOpen) |
|
879 |
{ |
|
880 |
RSqlStatement sqlSelectPreviewIconStmt; |
|
881 |
TInt err = sqlSelectPreviewIconStmt.Prepare(iSqlDb, |
|
882 |
KSelectPreviewIconStmt); |
|
883 |
||
884 |
QCRITICAL_WRITE_FORMAT("Error from Prepare()", err) |
|
885 |
||
886 |
if (err == KErrNone) |
|
887 |
{ |
|
888 |
//msg_id |
|
889 |
TInt msgIdIndex = sqlSelectPreviewIconStmt.ParameterIndex( |
|
890 |
_L(":message_id")); |
|
891 |
sqlSelectPreviewIconStmt.BindInt(msgIdIndex, msgId); |
|
892 |
||
893 |
// get preview-icon from DB |
|
894 |
err = sqlSelectPreviewIconStmt.Next(); |
|
895 |
QCRITICAL_WRITE_FORMAT("Error from Next()", err) |
|
896 |
||
897 |
if (err == KSqlAtRow) |
|
898 |
{ |
|
899 |
TInt previewIconIndex = sqlSelectPreviewIconStmt.ColumnIndex( |
|
900 |
_L("preview_icon")); |
|
901 |
||
902 |
RSqlColumnReadStream stream; |
|
903 |
||
904 |
//Get data from binary column BLOB |
|
905 |
err = stream.ColumnBinary(sqlSelectPreviewIconStmt, |
|
906 |
previewIconIndex); |
|
907 |
||
908 |
QCRITICAL_WRITE_FORMAT("Error from ColumnBinary()", err) |
|
909 |
||
910 |
if (err == KErrNone) |
|
911 |
{ |
|
912 |
CFbsBitmap *bitmap = new CFbsBitmap; |
|
913 |
TRAPD(err,bitmap->InternalizeL(stream)); |
|
914 |
QCRITICAL_WRITE_FORMAT("Error from bitmap InternalizeL()", err) |
|
915 |
||
916 |
//convert bitmap to pixmap |
|
917 |
if (err == KErrNone) |
|
918 |
{ |
|
919 |
TSize size = bitmap->SizeInPixels(); |
|
920 |
int bytesPerLine = bitmap->ScanLineLength(size.iWidth, |
|
921 |
bitmap->DisplayMode()); |
|
922 |
const uchar* dataPtr = |
|
923 |
(const uchar*) bitmap->DataAddress(); |
|
924 |
||
925 |
pixmap = QPixmap::fromImage(QImage(dataPtr, |
|
926 |
size.iWidth, size.iHeight, bytesPerLine, |
|
927 |
QImage::Format_RGB16)); |
|
928 |
||
929 |
imagePreviewed = true; |
|
930 |
||
931 |
QCRITICAL_WRITE("Bitmap Conversion completed") |
|
932 |
} |
|
933 |
//remove bitmap |
|
934 |
delete bitmap; |
|
935 |
} |
|
936 |
//close stream |
|
937 |
stream.Close(); |
|
938 |
} |
|
939 |
} |
|
940 |
sqlSelectPreviewIconStmt.Close(); |
|
941 |
} |
|
942 |
||
943 |
// if not found in db, set from file path |
|
944 |
if (!imagePreviewed) |
|
945 |
{ |
|
946 |
QPixmap orgPixmap(filePath); |
|
947 |
pixmap = orgPixmap.scaled(63.65, 63.65, Qt::IgnoreAspectRatio); |
|
948 |
} |
|
949 |
HbIcon * previewIcon = new HbIcon(pixmap); |
|
950 |
||
951 |
previewIconCache.insert(msgId, previewIcon); |
|
952 |
||
953 |
QCRITICAL_WRITE("ConversationsModel::updatePreviewIcon end.") |
|
954 |
||
955 |
} |
|
956 |
||
957 |
//--------------------------------------------------------------- |
|
958 |
// ConversationsModel::clearModel() |
|
959 |
// @see header |
|
960 |
//--------------------------------------------------------------- |
|
961 |
void ConversationsModel::clearModel() |
|
962 |
{ |
|
963 |
clear(); |
|
964 |
previewIconCache.clear(); |
|
965 |
} |
|
966 |
||
967 |
void ConversationsModel:: emitConversationViewEmpty() |
|
968 |
{ |
|
969 |
emit conversationViewEmpty(); |
|
970 |
} |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
971 |
//EOF |