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