author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 13:35:48 +0300 | |
changeset 34 | 84197e66a4bd |
parent 31 | ebfee66fde93 |
child 43 | 35b64624a9e7 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* class to manage differnt messaging views. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include "msgviewmanager.h" |
|
20 |
||
21 |
#include <HbMainWindow> |
|
22 |
#include <HbAction> |
|
23 |
#include <xqserviceutil.h> |
|
24 |
#include <QSqlQuery> |
|
25 |
#include <QSqlError> |
|
26 |
#include <HbApplication> |
|
27 |
#include <xqappmgr.h> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
28 |
#include <hbmessagebox.h> |
31 | 29 |
#include <HbView> |
30 |
||
31 |
#include "conversationsengine.h" |
|
32 |
#include "msglistview.h" |
|
33 |
#include "msgunieditorview.h" |
|
34 |
#include "msgconversationbaseview.h" |
|
35 |
#include "unifiedviewer.h" |
|
36 |
#include "draftslistview.h" |
|
37 |
#include "msgsettingsview.h" |
|
38 |
#include "convergedmessageid.h" |
|
39 |
#include "ringbc.h" |
|
40 |
#include "unidatamodelloader.h" |
|
41 |
#include "unidatamodelplugininterface.h" |
|
42 |
||
43 |
// LOCALIZATION |
|
44 |
#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
45 |
#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
46 |
#define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
47 |
#define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone") |
|
48 |
#define LOC_COMMON_SAVE hbTrId("txt_common_menu_save") |
|
49 |
||
50 |
const qint64 NULL_CONVERSATIONID = -1; |
|
51 |
||
52 |
MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent) : |
|
53 |
QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0), |
|
54 |
mUniViewer(0), mDraftsListView(0), mSettingsView(0), mBackAction(0), mServiceRequest( |
|
55 |
serviceRequest), mConversationId(-1), mViewServiceRequest(false),mMessageId(-1) |
|
56 |
{ |
|
57 |
//creating back action. |
|
58 |
mBackAction = new HbAction(Hb::BackNaviAction, this); |
|
59 |
connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
|
60 |
||
61 |
//create clv as first view if not a service request. |
|
62 |
if (!mServiceRequest) { |
|
63 |
QVariantList param; |
|
64 |
param << MsgBaseView::CLV; |
|
65 |
param << MsgBaseView::CLV; |
|
66 |
switchView(param); |
|
67 |
} |
|
68 |
else |
|
69 |
{ |
|
70 |
mDummyview = new HbView(); |
|
71 |
mMainWindow->addView(mDummyview); |
|
72 |
mMainWindow->setCurrentView(mDummyview); |
|
73 |
mViewTobeDeleted << mDummyview; |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
MsgViewManager::~MsgViewManager() |
|
78 |
{ |
|
79 |
// TODO Auto-generated destructor stub |
|
80 |
} |
|
81 |
||
82 |
void MsgViewManager::onBackAction() |
|
83 |
{ |
|
84 |
switch (mCurrentView) { |
|
85 |
case MsgBaseView::CLV: |
|
86 |
{ |
|
87 |
// if its viewer service then quit the application |
|
88 |
if (mViewServiceRequest) { |
|
89 |
HbApplication::quit(); |
|
90 |
break; |
|
91 |
} |
|
92 |
||
93 |
if (!mServiceRequest) { |
|
94 |
HbApplication::quit(); |
|
95 |
} |
|
96 |
else { |
|
97 |
completeServiceRequest(); |
|
98 |
} |
|
99 |
||
100 |
break; |
|
101 |
} |
|
102 |
||
103 |
case MsgBaseView::CV: |
|
104 |
{ |
|
105 |
//Save content to drafts before switching to clv |
|
106 |
mConversationView->saveContentToDrafts(); |
|
107 |
||
108 |
//marking messages as red in CV. |
|
109 |
mConversationView->markMessagesAsRead(); |
|
110 |
||
111 |
// reset the conversation id published |
|
112 |
mConversationView->setPSCVId(false); |
|
113 |
||
114 |
//clearing content of cv. |
|
115 |
mConversationView->clearContent(); |
|
116 |
||
117 |
// if service request for veiwer the just switch to univiewer. |
|
118 |
if (mViewServiceRequest) { |
|
119 |
mCurrentView = MsgBaseView::UNIVIEWER; |
|
120 |
mMainWindow->setCurrentView(mUniViewer); |
|
121 |
break; |
|
122 |
} |
|
123 |
||
124 |
if (mServiceRequest) { |
|
125 |
completeServiceRequest(); |
|
126 |
} |
|
127 |
else { |
|
128 |
//switch to clv. |
|
129 |
QVariantList param; |
|
130 |
param << MsgBaseView::CLV; |
|
131 |
param << MsgBaseView::CV; |
|
132 |
switchView(param); |
|
133 |
} |
|
134 |
||
135 |
break; |
|
136 |
} |
|
137 |
||
138 |
case MsgBaseView::DLV: |
|
139 |
{ |
|
140 |
if (mServiceRequest) { |
|
141 |
completeServiceRequest(); |
|
142 |
} |
|
143 |
else { |
|
144 |
//switch to clv. |
|
145 |
QVariantList param; |
|
146 |
param << MsgBaseView::CLV; |
|
147 |
param << MsgBaseView::DLV; |
|
148 |
switchView(param); |
|
149 |
} |
|
150 |
||
151 |
break; |
|
152 |
} |
|
153 |
||
154 |
case MsgBaseView::UNIEDITOR: |
|
155 |
{ |
|
156 |
//Save content to drafts before switching to clv |
|
157 |
mUniEditor->saveContentToDrafts(); |
|
158 |
||
159 |
// if service request for veiwer the just switch to univiewer. |
|
160 |
if (mViewServiceRequest) { |
|
161 |
mCurrentView = MsgBaseView::UNIVIEWER; |
|
162 |
mMainWindow->setCurrentView(mUniViewer); |
|
163 |
break; |
|
164 |
} |
|
165 |
||
166 |
//switch to clv. |
|
167 |
if (mServiceRequest) { |
|
168 |
completeServiceRequest(); |
|
169 |
} |
|
170 |
else { |
|
171 |
//switch to clv. |
|
172 |
QVariantList param; |
|
173 |
param << MsgBaseView::CLV; |
|
174 |
param << MsgBaseView::UNIEDITOR; |
|
175 |
switchView(param); |
|
176 |
} |
|
177 |
||
178 |
break; |
|
179 |
} |
|
180 |
||
181 |
case MsgBaseView::UNIVIEWER: |
|
182 |
{ |
|
183 |
// if its launched via service request quit the app |
|
184 |
if (mViewServiceRequest) { |
|
185 |
HbApplication::quit(); |
|
186 |
} |
|
187 |
else { |
|
188 |
QVariantList param; |
|
189 |
param << MsgBaseView::CV; |
|
190 |
param << MsgBaseView::UNIVIEWER; |
|
191 |
param << mConversationId; |
|
192 |
switchView(param); |
|
193 |
||
194 |
} |
|
195 |
break; |
|
196 |
} |
|
197 |
case MsgBaseView::MSGSETTINGS: |
|
198 |
{ |
|
199 |
QVariantList param; |
|
200 |
param << MsgBaseView::DEFAULT; |
|
201 |
param << MsgBaseView::MSGSETTINGS; |
|
202 |
switchView(param); |
|
203 |
break; |
|
204 |
} |
|
205 |
default: |
|
206 |
{ |
|
207 |
break; |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
void MsgViewManager::switchView(const QVariantList& data) |
|
213 |
{ |
|
214 |
||
215 |
int viewId = data.at(0).toInt(); |
|
216 |
||
217 |
switch (viewId) { |
|
218 |
case MsgBaseView::DEFAULT: |
|
219 |
{ |
|
220 |
handleDefault(data); |
|
221 |
break; |
|
222 |
} |
|
223 |
case MsgBaseView::CLV: |
|
224 |
{ |
|
225 |
switchToClv(data); |
|
226 |
break; |
|
227 |
} |
|
228 |
||
229 |
case MsgBaseView::CV: |
|
230 |
{ |
|
231 |
||
232 |
switchToCv(data); |
|
233 |
break; |
|
234 |
} |
|
235 |
||
236 |
case MsgBaseView::DLV: |
|
237 |
{ |
|
238 |
switchToDlv(data); |
|
239 |
break; |
|
240 |
} |
|
241 |
||
242 |
case MsgBaseView::UNIEDITOR: |
|
243 |
{ |
|
244 |
switchToUniEditor(data); |
|
245 |
break; |
|
246 |
} |
|
247 |
||
248 |
case MsgBaseView::UNIVIEWER: |
|
249 |
{ |
|
250 |
switchToUniViewer(data); |
|
251 |
break; |
|
252 |
} |
|
253 |
||
254 |
case MsgBaseView::MSGSETTINGS: |
|
255 |
{ |
|
256 |
switchToMsgSettings(data); |
|
257 |
break; |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
||
262 |
void MsgViewManager::deletePreviousView() |
|
263 |
{ |
|
264 |
while(mViewTobeDeleted.count()) |
|
265 |
{ |
|
266 |
HbView* v = mViewTobeDeleted.takeAt(0); |
|
267 |
mMainWindow->removeView(v); |
|
268 |
delete v; |
|
269 |
} |
|
270 |
disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView())); |
|
271 |
} |
|
272 |
||
273 |
||
274 |
void MsgViewManager::send(const qint32 contactId, const QString phoneNumber, |
|
275 |
const QString displayName) |
|
276 |
{ |
|
277 |
qint64 conversationId = ConversationsEngine::instance()-> getConversationIdFromContactId( |
|
278 |
contactId); |
|
279 |
||
280 |
//set mode to viewer, if conversations found else send mode. |
|
281 |
QVariantList param; |
|
282 |
if (conversationId > 0) { |
|
283 |
param << MsgBaseView::CV; |
|
284 |
param << MsgBaseView::SERVICE; |
|
285 |
param << conversationId; |
|
286 |
} |
|
287 |
else { |
|
288 |
ConvergedMessage message; |
|
289 |
ConvergedMessageAddress address; |
|
290 |
address.setAddress(phoneNumber); |
|
291 |
address.setAlias(displayName); |
|
292 |
message.addToRecipient(address); |
|
293 |
||
294 |
QByteArray dataArray; |
|
295 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
296 |
message.serialize(messageStream); |
|
297 |
||
298 |
param << MsgBaseView::UNIEDITOR; |
|
299 |
param << MsgBaseView::SERVICE; |
|
300 |
param << dataArray; |
|
301 |
} |
|
302 |
switchView(param); |
|
303 |
XQServiceUtil::toBackground(false); |
|
304 |
} |
|
305 |
||
306 |
void MsgViewManager::send(const QString phoneNumber, const QString alias, const QString bodyText) |
|
307 |
{ |
|
308 |
ConvergedMessage message; |
|
309 |
ConvergedMessageAddress address; |
|
310 |
address.setAddress(phoneNumber); |
|
311 |
address.setAlias(alias); |
|
312 |
message.addToRecipient(address); |
|
313 |
message.setBodyText(bodyText); |
|
314 |
||
315 |
QVariantList param; |
|
316 |
QByteArray dataArray; |
|
317 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
318 |
message.serialize(messageStream); |
|
319 |
||
320 |
param << MsgBaseView::UNIEDITOR; |
|
321 |
param << MsgBaseView::SERVICE; |
|
322 |
param << dataArray; |
|
323 |
||
324 |
switchView(param); |
|
325 |
XQServiceUtil::toBackground(false); |
|
326 |
} |
|
327 |
||
328 |
void MsgViewManager::setServiceRequest(bool request) |
|
329 |
{ |
|
330 |
mServiceRequest = request; |
|
331 |
mViewAtServiceRequest = mCurrentView; |
|
332 |
} |
|
333 |
||
334 |
void MsgViewManager::switchToLastSavedView() |
|
335 |
{ |
|
336 |
QVariantList param; |
|
337 |
||
338 |
switch (mViewAtServiceRequest) { |
|
339 |
case MsgBaseView::CV: |
|
340 |
{ |
|
341 |
param << MsgBaseView::CV; |
|
342 |
param << MsgBaseView::SERVICE; |
|
343 |
param << mConversationId; |
|
344 |
break; |
|
345 |
} |
|
346 |
case MsgBaseView::UNIVIEWER: |
|
347 |
{ |
|
348 |
param << MsgBaseView::UNIVIEWER; |
|
349 |
param << MsgBaseView::SERVICE; |
|
350 |
break; |
|
351 |
} |
|
352 |
default: |
|
353 |
{ |
|
354 |
param << MsgBaseView::CLV; |
|
355 |
param << MsgBaseView::SERVICE; |
|
356 |
break; |
|
357 |
} |
|
358 |
} |
|
359 |
switchView(param); |
|
360 |
} |
|
361 |
||
362 |
void MsgViewManager::open(qint64 conversationId) |
|
363 |
{ |
|
364 |
QVariantList param; |
|
365 |
||
366 |
if (conversationId < 0) { |
|
367 |
param << MsgBaseView::CLV; |
|
368 |
param << MsgBaseView::SERVICE; |
|
369 |
||
370 |
if( mCurrentView == MsgBaseView::CV && mConversationView) |
|
371 |
{ |
|
372 |
mConversationView->setPSCVId(false); |
|
373 |
} |
|
374 |
} |
|
375 |
else { |
|
376 |
param << MsgBaseView::CV; |
|
377 |
param << MsgBaseView::SERVICE; |
|
378 |
param << conversationId; |
|
379 |
} |
|
380 |
||
381 |
switchView(param); |
|
382 |
XQServiceUtil::toBackground(false); |
|
383 |
} |
|
384 |
||
385 |
void MsgViewManager::send(QVariant data) |
|
386 |
{ |
|
387 |
ConvergedMessage message; |
|
388 |
ConvergedMessageAttachmentList attachmentList; |
|
389 |
// handle multiple files from sendUI |
|
390 |
// e.g. contacts can send multiple vcards |
|
391 |
QStringList receivedFiles = data.toStringList(); |
|
392 |
int recFileCount = receivedFiles.count(); |
|
393 |
for (int i = 0; i < recFileCount; i++) { |
|
394 |
ConvergedMessageAttachment *attachment = |
|
395 |
new ConvergedMessageAttachment(receivedFiles.at(i)); |
|
396 |
attachmentList.append(attachment); |
|
397 |
} |
|
398 |
message.addAttachments(attachmentList); |
|
399 |
||
400 |
QByteArray dataArray; |
|
401 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
402 |
message.serialize(messageStream); |
|
403 |
||
404 |
QVariantList param; |
|
405 |
param << MsgBaseView::UNIEDITOR; |
|
406 |
param << MsgBaseView::SERVICE; |
|
407 |
param << dataArray; |
|
408 |
||
409 |
switchView(param); |
|
410 |
XQServiceUtil::toBackground(false); |
|
411 |
} |
|
412 |
||
413 |
qint64 MsgViewManager::findConversationId(const QString phoneNum) |
|
414 |
{ |
|
415 |
return ConversationsEngine::instance()-> getConversationIdFromAddress(phoneNum); |
|
416 |
} |
|
417 |
||
418 |
//will be depricated in future. |
|
419 |
void MsgViewManager::openEditor(QString phoneNumber, QString name) |
|
420 |
{ |
|
421 |
ConvergedMessage message; |
|
422 |
ConvergedMessageAddress address; |
|
423 |
address.setAddress(phoneNumber); |
|
424 |
address.setAlias(name); |
|
425 |
message.addToRecipient(address); |
|
426 |
||
427 |
QByteArray dataArray; |
|
428 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
429 |
message.serialize(messageStream); |
|
430 |
||
431 |
QVariantList param; |
|
432 |
param << MsgBaseView::UNIEDITOR; |
|
433 |
param << MsgBaseView::SERVICE; |
|
434 |
param << dataArray; |
|
435 |
||
436 |
switchView(param); |
|
437 |
XQServiceUtil::toBackground(false); |
|
438 |
} |
|
439 |
||
440 |
void MsgViewManager::completeServiceRequest() |
|
441 |
{ |
|
442 |
mServiceRequest = false; |
|
443 |
XQServiceUtil::toBackground(true); |
|
444 |
switchToLastSavedView(); |
|
445 |
} |
|
446 |
||
447 |
void MsgViewManager::switchToClv(const QVariantList& data) |
|
448 |
{ |
|
449 |
//switch to CLV. |
|
450 |
mCurrentView = MsgBaseView::CLV; |
|
451 |
mPreviousView = data.at(1).toInt(); |
|
452 |
||
453 |
// delete case from viewer service |
|
454 |
if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
|
455 |
// quit the application |
|
456 |
HbApplication::quit(); |
|
457 |
} |
|
458 |
||
459 |
if (mConversationView) { |
|
460 |
mConversationView->saveContentToDrafts(); |
|
461 |
//clearing content of cv. |
|
462 |
mConversationView->clearContent(); |
|
463 |
} |
|
464 |
||
465 |
if (!mListView) { |
|
466 |
mListView = new MsgListView(); |
|
467 |
mListView->setNavigationAction(mBackAction); |
|
468 |
connect(mListView, SIGNAL(switchView(const QVariantList&)), this, |
|
469 |
SLOT(switchView(const QVariantList&))); |
|
470 |
mMainWindow->addView(mListView); |
|
471 |
} |
|
472 |
||
473 |
mMainWindow->setCurrentView(mListView); |
|
474 |
||
475 |
//delete UniEditor |
|
476 |
if (mUniEditor) |
|
477 |
{ |
|
478 |
appendViewToBeDeleted(mUniEditor); |
|
479 |
mUniEditor = NULL; |
|
480 |
} |
|
481 |
||
482 |
//delete UniViewer |
|
483 |
if (mUniViewer) |
|
484 |
{ |
|
485 |
appendViewToBeDeleted(mUniViewer); |
|
486 |
mUniViewer = NULL; |
|
487 |
} |
|
488 |
} |
|
489 |
||
490 |
void MsgViewManager::switchToCv(const QVariantList& data) |
|
491 |
{ |
|
492 |
//switch to CV. |
|
493 |
mCurrentView = MsgBaseView::CV; |
|
494 |
mPreviousView = data.at(1).toInt(); |
|
495 |
||
496 |
// delete case from viewer service |
|
497 |
if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
|
498 |
// quit the application |
|
499 |
HbApplication::quit(); |
|
500 |
} |
|
501 |
||
502 |
QVariant var = data.at(2); |
|
503 |
qint64 conversationId; |
|
504 |
if (var.type() == QVariant::String) { |
|
505 |
QString phoneNumber = var.toString(); |
|
506 |
conversationId = findConversationId(phoneNumber); |
|
507 |
||
508 |
if (conversationId == NULL_CONVERSATIONID) { |
|
509 |
QVariantList param; |
|
510 |
param << MsgBaseView::CLV; |
|
511 |
param << MsgBaseView::CV; |
|
512 |
||
513 |
if( mCurrentView == MsgBaseView::CV && mConversationView){ |
|
514 |
mConversationView->setPSCVId(false); |
|
515 |
} |
|
516 |
||
517 |
switchView(param); |
|
518 |
return; |
|
519 |
} |
|
520 |
} |
|
521 |
else if (var.type() == QVariant::Invalid) { |
|
522 |
// this case comes when a message is deleted from |
|
523 |
// Unified viewer set curent view as conversation view |
|
524 |
// and return |
|
525 |
mMainWindow->setCurrentView(mConversationView); |
|
526 |
||
527 |
// publish already opened conversation's id |
|
528 |
mConversationView->setPSCVId(true); |
|
529 |
||
530 |
if (mUniViewer) |
|
531 |
{ |
|
532 |
appendViewToBeDeleted(mUniViewer); |
|
533 |
mUniViewer = NULL; |
|
534 |
} |
|
535 |
||
536 |
return; |
|
537 |
} |
|
538 |
else { |
|
539 |
conversationId = var.toLongLong(); |
|
540 |
} |
|
541 |
//switch to CV. |
|
542 |
mConversationId = conversationId; |
|
543 |
||
544 |
if (!mConversationView) { |
|
545 |
mConversationView = new MsgConversationBaseView(); |
|
546 |
mConversationView->setNavigationAction(mBackAction); |
|
547 |
connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
|
548 |
SLOT(switchView(const QVariantList&))); |
|
549 |
||
550 |
mMainWindow->addView(mConversationView); |
|
551 |
} |
|
552 |
else if (mConversationView->conversationId() != mConversationId){ |
|
553 |
//Save content to drafts before switching to different CV |
|
554 |
mConversationView->saveContentToDrafts(); |
|
555 |
//clearing content of current cv. |
|
556 |
mConversationView->clearContent(); |
|
557 |
} |
|
558 |
||
559 |
mConversationView->openConversation(conversationId); |
|
560 |
||
561 |
if (mServiceRequest) { |
|
562 |
mMainWindow->setCurrentView(mConversationView); |
|
563 |
} |
|
564 |
else { |
|
565 |
mMainWindow->setCurrentView(mConversationView); |
|
566 |
} |
|
567 |
||
568 |
//delete UniEditor |
|
569 |
if (mUniEditor) |
|
570 |
{ |
|
571 |
appendViewToBeDeleted(mUniEditor); |
|
572 |
mUniEditor = NULL; |
|
573 |
} |
|
574 |
||
575 |
//delete UniViewer |
|
576 |
if (mUniViewer) |
|
577 |
{ |
|
578 |
appendViewToBeDeleted(mUniViewer); |
|
579 |
mUniViewer = NULL; |
|
580 |
} |
|
581 |
} |
|
582 |
||
583 |
void MsgViewManager::switchToDlv(const QVariantList& data) |
|
584 |
{ |
|
585 |
//switch to DLV. |
|
586 |
mCurrentView = MsgBaseView::DLV; |
|
587 |
mPreviousView = data.at(1).toInt(); |
|
588 |
||
589 |
if (!mDraftsListView) { |
|
590 |
mDraftsListView = new DraftsListView(); |
|
591 |
mDraftsListView->setNavigationAction(mBackAction); |
|
592 |
connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this, |
|
593 |
SLOT(switchView(const QVariantList&))); |
|
594 |
||
595 |
mMainWindow->addView(mDraftsListView); |
|
596 |
} |
|
597 |
mMainWindow->setCurrentView(mDraftsListView); |
|
598 |
} |
|
599 |
||
600 |
void MsgViewManager::switchToUniEditor(const QVariantList& data) |
|
601 |
{ |
|
602 |
/** |
|
603 |
* Editor is tried to open again before exiting the previously |
|
604 |
* opened editor. Multi taping in DLV or Forward. |
|
605 |
*/ |
|
606 |
if (mUniEditor) { |
|
607 |
return; |
|
608 |
} |
|
609 |
||
610 |
mCurrentView = MsgBaseView::UNIEDITOR; |
|
611 |
mPreviousView = data.at(1).toInt(); |
|
612 |
||
613 |
if (mConversationView) { |
|
614 |
//clearing content of cv. |
|
615 |
mConversationView->clearContent(); |
|
616 |
} |
|
617 |
||
618 |
// reset conversation id published |
|
619 |
if(mPreviousView == MsgBaseView::CV && mConversationView) |
|
620 |
{ |
|
621 |
mConversationView->setPSCVId(false); |
|
622 |
} |
|
623 |
||
624 |
//swich to unieditor. |
|
625 |
if (!mUniEditor) { |
|
626 |
mUniEditor = new MsgUnifiedEditorView(); |
|
627 |
mMainWindow->addView(mUniEditor); |
|
628 |
mUniEditor->setNavigationAction(mBackAction); |
|
629 |
connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this, |
|
630 |
SLOT(switchView(const QVariantList&))); |
|
631 |
} |
|
632 |
||
633 |
// check if additional data for unieditor's consumption is available |
|
634 |
if (data.length() > 2) { |
|
635 |
QVariantList editorData; |
|
636 |
// i=2 because view manager consumed first two args |
|
637 |
for (int i = 2; i < data.length(); i++) { |
|
638 |
editorData << data.at(i); |
|
639 |
} |
|
640 |
||
641 |
if (MsgBaseView::DLV == mPreviousView) { |
|
642 |
mUniEditor->openDraftsMessage(editorData); |
|
643 |
} |
|
644 |
else { |
|
645 |
mUniEditor->populateContent(editorData); |
|
646 |
} |
|
647 |
} |
|
648 |
||
649 |
if (mServiceRequest) { |
|
650 |
mMainWindow->setCurrentView(mUniEditor); |
|
651 |
} |
|
652 |
else { |
|
653 |
mMainWindow->setCurrentView(mUniEditor); |
|
654 |
} |
|
655 |
//delete UniViewer |
|
656 |
if (mUniViewer ) |
|
657 |
{ |
|
658 |
appendViewToBeDeleted(mUniViewer); |
|
659 |
mUniViewer = NULL; |
|
660 |
} |
|
661 |
} |
|
662 |
||
663 |
void MsgViewManager::switchToUniViewer(const QVariantList& data) |
|
664 |
{ |
|
665 |
/** |
|
666 |
* Viewer is tried to open again before exiting the previously |
|
667 |
* opened viewer. Multi taping bubbles in CV. |
|
668 |
*/ |
|
669 |
if (mUniViewer) { |
|
670 |
return; |
|
671 |
} |
|
672 |
||
673 |
mCurrentView = MsgBaseView::UNIVIEWER; |
|
674 |
mPreviousView = data.at(1).toInt(); |
|
675 |
||
676 |
//switch to univiewer. |
|
677 |
if (data.length() > 2) { |
|
678 |
qint32 contactId = data.at(2).toLongLong(); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
679 |
qint32 messageId = data.at(3).toInt(); |
31 | 680 |
int msgCount = data.at(4).toInt(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
681 |
int canForwardMessage = data.at(5).toInt(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
682 |
|
31 | 683 |
if (!mUniViewer) { |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
684 |
mUniViewer = new UnifiedViewer(messageId, canForwardMessage); |
31 | 685 |
mUniViewer->setNavigationAction(mBackAction); |
686 |
mMainWindow->addView(mUniViewer); |
|
687 |
connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this, |
|
688 |
SLOT(switchView(const QVariantList&))); |
|
689 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
690 |
mUniViewer->populateContent(messageId, true, msgCount); |
31 | 691 |
} |
692 |
||
693 |
if(mPreviousView==MsgBaseView::CV && mConversationView) |
|
694 |
{ |
|
695 |
mConversationView->setPSCVId(false); |
|
696 |
} |
|
697 |
||
698 |
mMainWindow->setCurrentView(mUniViewer); |
|
699 |
} |
|
700 |
void MsgViewManager::switchToMsgSettings(const QVariantList& data) |
|
701 |
{ |
|
702 |
mCurrentView = MsgBaseView::MSGSETTINGS; |
|
703 |
mPreviousView = data.at(1).toInt(); |
|
704 |
||
705 |
if (!mSettingsView) { |
|
706 |
||
707 |
MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView; |
|
708 |
if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView |
|
709 |
== MsgBaseView::CV) |
|
710 |
{ |
|
711 |
view = (MsgSettingsView::SettingsView)data.at(2).toInt(); |
|
712 |
} |
|
713 |
||
714 |
mSettingsView = new MsgSettingsView(view); |
|
715 |
mSettingsView->setNavigationAction(mBackAction); |
|
716 |
mMainWindow->addView(mSettingsView); |
|
717 |
mMainWindow->setCurrentView(mSettingsView); |
|
718 |
} |
|
719 |
if(mPreviousView==MsgBaseView::CV && mConversationView){ |
|
720 |
mConversationView->setPSCVId(false); |
|
721 |
} |
|
722 |
} |
|
723 |
||
724 |
void MsgViewManager::handleDefault(const QVariantList& data) |
|
725 |
{ |
|
726 |
//special handling incase we switch from settings-view |
|
727 |
int previousViewId = data.at(1).toInt(); |
|
728 |
if (MsgBaseView::MSGSETTINGS == previousViewId) { |
|
729 |
//switch to view, where from settings view was launched |
|
730 |
mCurrentView = mPreviousView; |
|
731 |
mPreviousView = previousViewId; |
|
732 |
//remove the settings view from main window |
|
733 |
if (mSettingsView) |
|
734 |
{ |
|
735 |
appendViewToBeDeleted(mSettingsView); |
|
736 |
mSettingsView = NULL; |
|
737 |
} |
|
738 |
switch (mCurrentView) { |
|
739 |
case MsgBaseView::CLV: |
|
740 |
{ |
|
741 |
if (mListView) |
|
742 |
mMainWindow->setCurrentView(mListView); |
|
743 |
break; |
|
744 |
} |
|
745 |
case MsgBaseView::CV: |
|
746 |
{ |
|
747 |
if (mConversationView) |
|
748 |
mMainWindow->setCurrentView(mConversationView); |
|
749 |
break; |
|
750 |
} |
|
751 |
case MsgBaseView::DLV: |
|
752 |
{ |
|
753 |
if (mDraftsListView) |
|
754 |
mMainWindow->setCurrentView(mDraftsListView); |
|
755 |
break; |
|
756 |
} |
|
757 |
case MsgBaseView::UNIEDITOR: |
|
758 |
{ |
|
759 |
if (mServiceRequest) { |
|
760 |
mMainWindow->setCurrentView(mUniEditor); |
|
761 |
} |
|
762 |
else { |
|
763 |
mMainWindow->setCurrentView(mUniEditor); |
|
764 |
} |
|
765 |
break; |
|
766 |
} |
|
767 |
} |
|
768 |
} |
|
769 |
} |
|
770 |
||
771 |
void MsgViewManager::view(int msgId) |
|
772 |
{ |
|
773 |
int msgType; |
|
774 |
int msgSubType; |
|
775 |
mMessageId = msgId; |
|
776 |
qint32 messageId(msgId); |
|
777 |
ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType); |
|
778 |
||
779 |
switch (msgType) { |
|
780 |
case ConvergedMessage::Sms: |
|
781 |
case ConvergedMessage::Mms: |
|
782 |
case ConvergedMessage::MmsNotification: |
|
783 |
{ |
|
784 |
handleSmsMmsMsg(msgId); |
|
785 |
break; |
|
786 |
} |
|
787 |
case ConvergedMessage::BioMsg: |
|
788 |
{ |
|
789 |
if (msgSubType == ConvergedMessage::RingingTone) { |
|
790 |
handleRingtoneMsg(msgId); |
|
791 |
||
792 |
} |
|
793 |
else if (msgSubType == ConvergedMessage::Provisioning) { |
|
794 |
handleProvisoningMsg(msgId); |
|
795 |
} |
|
796 |
break; |
|
797 |
} |
|
798 |
case ConvergedMessage::BT: |
|
799 |
{ |
|
800 |
break; |
|
801 |
} |
|
802 |
default: |
|
803 |
{ |
|
804 |
// for un supported message show delete option |
|
805 |
HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)), |
|
806 |
LOC_BUTTON_DELETE, |
|
807 |
LOC_BUTTON_CANCEL); |
|
808 |
break; |
|
809 |
} |
|
810 |
} |
|
811 |
} |
|
812 |
||
813 |
// ---------------------------------------------------------------------------- |
|
814 |
// MsgViewManager::handleSmsMmsMsg |
|
815 |
// @see header |
|
816 |
// ---------------------------------------------------------------------------- |
|
817 |
void MsgViewManager::handleSmsMmsMsg(int msgId) |
|
818 |
{ |
|
819 |
mViewServiceRequest = true; |
|
820 |
||
821 |
mCurrentView = MsgBaseView::UNIVIEWER; |
|
822 |
||
823 |
if (!mUniViewer) { |
|
824 |
mUniViewer = new UnifiedViewer(msgId); |
|
825 |
mUniViewer->setNavigationAction(mBackAction); |
|
826 |
mMainWindow->addView(mUniViewer); |
|
827 |
connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this, |
|
828 |
SLOT(switchView(const QVariantList&))); |
|
829 |
} |
|
830 |
mUniViewer->populateContent(msgId, true, -1); |
|
831 |
||
832 |
mMainWindow->setCurrentView(mUniViewer); |
|
833 |
} |
|
834 |
||
835 |
// ---------------------------------------------------------------------------- |
|
836 |
// MsgViewManager::handleRingtoneMsg |
|
837 |
// @see header |
|
838 |
// ---------------------------------------------------------------------------- |
|
839 |
void MsgViewManager::handleRingtoneMsg(int msgId) |
|
840 |
{ |
|
841 |
mMessageId = msgId; |
|
842 |
HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this, |
|
843 |
SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL); |
|
844 |
} |
|
845 |
||
846 |
// ---------------------------------------------------------------------------- |
|
847 |
// MsgViewManager::handleProvisoningMsg |
|
848 |
// @see header |
|
849 |
// ---------------------------------------------------------------------------- |
|
850 |
void MsgViewManager::handleProvisoningMsg(int msgId) |
|
851 |
{ |
|
852 |
QString messageId; |
|
853 |
messageId.setNum(msgId); |
|
854 |
||
855 |
XQApplicationManager* aiwMgr = new XQApplicationManager(); |
|
856 |
||
857 |
XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM", "Provisioning", |
|
858 |
"ProcessMessage(QString)", true); // embedded |
|
859 |
||
860 |
if (request) { |
|
861 |
QList<QVariant> args; |
|
862 |
args << QVariant(messageId); |
|
863 |
request->setArguments(args); |
|
864 |
||
865 |
// Send the request |
|
866 |
bool res = request->send(); |
|
867 |
||
868 |
// Cleanup |
|
869 |
delete request; |
|
870 |
} |
|
871 |
||
872 |
delete aiwMgr; |
|
873 |
||
874 |
// close the application once its handled |
|
875 |
HbApplication::quit(); |
|
876 |
} |
|
877 |
||
878 |
void MsgViewManager::setViewInteractive() |
|
879 |
{ |
|
880 |
if(!mMainWindow->isInteractive()) |
|
881 |
{ |
|
882 |
mMainWindow->setInteractive(true); |
|
883 |
} |
|
884 |
||
885 |
disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive())); |
|
886 |
} |
|
887 |
||
888 |
void MsgViewManager::appendViewToBeDeleted(HbView* view) |
|
889 |
{ |
|
890 |
if (view) |
|
891 |
{ |
|
892 |
mViewTobeDeleted << view; |
|
893 |
connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView())); |
|
894 |
} |
|
895 |
} |
|
896 |
||
897 |
// ---------------------------------------------------------------------------- |
|
898 |
// MsgViewManager::onDialogDeleteMsg |
|
899 |
// @see header |
|
900 |
// ---------------------------------------------------------------------------- |
|
901 |
void MsgViewManager::onDialogDeleteMsg(HbAction* action) |
|
902 |
{ |
|
903 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
904 |
if (action == dlg->actions().at(0)) { |
|
905 |
QList<int> msgIdList; |
|
906 |
msgIdList << mMessageId; |
|
907 |
ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
908 |
} |
|
909 |
HbApplication::quit(); // exit after handling |
|
910 |
} |
|
911 |
||
912 |
// ---------------------------------------------------------------------------- |
|
913 |
// MsgViewManager::onDialogSaveTone |
|
914 |
// @see header |
|
915 |
// ---------------------------------------------------------------------------- |
|
916 |
void MsgViewManager::onDialogSaveTone(HbAction* action) |
|
917 |
{ |
|
918 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
919 |
if (action == dlg->actions().at(0)) { |
|
920 |
UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
|
921 |
UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin( |
|
922 |
ConvergedMessage::BioMsg); |
|
923 |
pluginInterface->setMessageId(mMessageId); |
|
924 |
UniMessageInfoList attachments = pluginInterface->attachmentList(); |
|
925 |
||
926 |
QString attachmentPath = attachments.at(0)->path(); |
|
927 |
||
928 |
RingBc* ringBc = new RingBc(); |
|
929 |
ringBc->saveTone(attachmentPath); |
|
930 |
||
931 |
// clear attachement list : its allocated at data model |
|
932 |
while (!attachments.isEmpty()) { |
|
933 |
delete attachments.takeFirst(); |
|
934 |
} |
|
935 |
||
936 |
delete ringBc; |
|
937 |
delete pluginLoader; |
|
938 |
} |
|
939 |
||
940 |
// close the application once its handled |
|
941 |
HbApplication::quit(); |
|
942 |
} |
|
943 |
||
34
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 |
// MsgViewManager::currentView |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
946 |
// @see header |
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 |
int MsgViewManager::currentView() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
949 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
950 |
return mCurrentView; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
951 |
} |