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