37
|
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: Manages differnt messaging views.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "msgserviceviewmanager.h"
|
|
19 |
|
67
|
20 |
#include <QFileInfo>
|
|
21 |
#include <QDir>
|
|
22 |
#include <QFile>
|
51
|
23 |
#include <QPixmap>
|
37
|
24 |
#include <HbMainWindow>
|
|
25 |
#include <HbAction>
|
|
26 |
#include <HbApplication>
|
67
|
27 |
#include <HbMessageBox>
|
|
28 |
#include <HbDeviceMessageBox>
|
|
29 |
#include <HbSplashScreen>
|
37
|
30 |
|
|
31 |
#include <xqserviceutil.h>
|
|
32 |
#include <xqappmgr.h>
|
73
|
33 |
#include <xqaiwdecl.h>
|
37
|
34 |
|
|
35 |
#include "msgunieditorview.h"
|
|
36 |
#include "unifiedviewer.h"
|
|
37 |
#include "msgstorehandler.h"
|
|
38 |
#include "msgsettingsview.h"
|
|
39 |
#include "convergedmessageid.h"
|
|
40 |
#include "ringbc.h"
|
|
41 |
#include "unidatamodelloader.h"
|
|
42 |
#include "unidatamodelplugininterface.h"
|
|
43 |
|
51
|
44 |
// CONSTANTS
|
|
45 |
static const char SEND_EFFECT[] = "sendeffect";
|
|
46 |
static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml";
|
|
47 |
|
37
|
48 |
// LOCALIZATION
|
73
|
49 |
#define LOC_DELETED_MESSAGE hbTrId("txt_messages_dialog_message_has_been_deleted")
|
|
50 |
#define LOC_CANNOT_OPEN_MESSAGE hbTrId("txt_messages_dialog_message_is_outgoingcannot_be")
|
|
51 |
#define LOC_UNKNOWN_MSG_TYPE hbTrId("txt_messages_dialog_unsupported_message_type")
|
|
52 |
#define LOC_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
|
37
|
53 |
|
|
54 |
//----------------------------------------------------------------------------
|
|
55 |
// MsgViewInterface::MsgViewInterface
|
|
56 |
// @see header
|
|
57 |
//----------------------------------------------------------------------------
|
|
58 |
MsgServiceViewManager::MsgServiceViewManager(MsgStoreHandler* storeHandler,
|
|
59 |
HbMainWindow* mainWindow, QObject* parent) :
|
|
60 |
QObject(parent), mMainWindow(mainWindow), mUniEditor(NULL),
|
|
61 |
mUniViewer(NULL), mSettingsView(NULL), mBackAction(NULL),
|
67
|
62 |
mStoreHandler(storeHandler)
|
37
|
63 |
{
|
|
64 |
//creating back action.
|
|
65 |
mBackAction = new HbAction(Hb::BackNaviAction, this);
|
|
66 |
connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
|
|
67 |
|
|
68 |
// create a temp view : which is required for lazy loading of other views
|
|
69 |
HbView* tempView = new HbView();
|
|
70 |
mMainWindow->addView(tempView);
|
|
71 |
mMainWindow->setCurrentView(tempView);
|
|
72 |
}
|
|
73 |
|
|
74 |
//----------------------------------------------------------------------------
|
|
75 |
// MsgServiceViewManager::~MsgServiceViewManager
|
|
76 |
// @see header
|
|
77 |
//----------------------------------------------------------------------------
|
|
78 |
MsgServiceViewManager::~MsgServiceViewManager()
|
|
79 |
{
|
|
80 |
|
|
81 |
}
|
|
82 |
|
|
83 |
//----------------------------------------------------------------------------
|
|
84 |
// MsgServiceViewManager::onBackAction
|
|
85 |
// @see header
|
|
86 |
//----------------------------------------------------------------------------
|
|
87 |
void MsgServiceViewManager::onBackAction()
|
|
88 |
{
|
|
89 |
switch(mCurrentView)
|
|
90 |
{
|
|
91 |
case MsgBaseView::UNIEDITOR:
|
|
92 |
{
|
|
93 |
HbApplication::quit();
|
|
94 |
break;
|
|
95 |
}
|
|
96 |
case MsgBaseView::MSGSETTINGS:
|
|
97 |
{
|
|
98 |
//delete the settings instance
|
|
99 |
if (mSettingsView)
|
|
100 |
{
|
|
101 |
mMainWindow->removeView(mSettingsView);
|
|
102 |
delete mSettingsView;
|
|
103 |
mSettingsView = NULL;
|
|
104 |
}
|
|
105 |
if(mUniEditor)
|
|
106 |
{
|
|
107 |
mMainWindow->setCurrentView(mUniEditor);
|
|
108 |
mCurrentView = MsgBaseView::UNIEDITOR;
|
|
109 |
}
|
|
110 |
else
|
|
111 |
{
|
|
112 |
ConvergedMessage message;
|
|
113 |
QVariantList param;
|
|
114 |
QByteArray dataArray;
|
|
115 |
QDataStream messageStream(&dataArray,
|
|
116 |
QIODevice::WriteOnly | QIODevice::Append);
|
|
117 |
message.serialize(messageStream);
|
|
118 |
param << dataArray;
|
|
119 |
|
|
120 |
// switch to editor
|
|
121 |
switchToUniEditor(param);
|
|
122 |
}
|
|
123 |
break;
|
|
124 |
}
|
|
125 |
case MsgBaseView::UNIVIEWER:
|
|
126 |
default:
|
|
127 |
{
|
|
128 |
HbApplication::quit();
|
|
129 |
break;
|
|
130 |
}
|
|
131 |
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
//----------------------------------------------------------------------------
|
|
136 |
// MsgServiceViewManager::switchView
|
|
137 |
// @see header
|
|
138 |
//----------------------------------------------------------------------------
|
|
139 |
void MsgServiceViewManager::switchView(const QVariantList& data)
|
|
140 |
{
|
|
141 |
int viewId = data.at(0).toInt();
|
51
|
142 |
switch (viewId)
|
|
143 |
{
|
37
|
144 |
case MsgBaseView::UNIEDITOR:
|
|
145 |
{
|
|
146 |
// except first 2 parameters pass other parameters
|
|
147 |
QVariantList editorData;
|
|
148 |
for(int a = 2; a < data.length(); ++a)
|
|
149 |
{
|
|
150 |
editorData << data.at(a);
|
|
151 |
}
|
|
152 |
switchToUniEditor(editorData);
|
|
153 |
break;
|
|
154 |
}
|
|
155 |
case MsgBaseView::MSGSETTINGS:
|
|
156 |
{
|
|
157 |
switchToMsgSettings(data);
|
|
158 |
break;
|
|
159 |
}
|
|
160 |
default:
|
|
161 |
{
|
51
|
162 |
// if send from editor is successful, then run effects
|
|
163 |
int previousView = data.at(1).toInt();
|
|
164 |
if(previousView == MsgBaseView::UNIEDITOR)
|
|
165 |
{
|
|
166 |
startAnimation(SEND_EFFECT);
|
|
167 |
}
|
|
168 |
else
|
|
169 |
{
|
|
170 |
HbApplication::quit();
|
|
171 |
}
|
37
|
172 |
}
|
51
|
173 |
}
|
37
|
174 |
}
|
|
175 |
|
|
176 |
//----------------------------------------------------------------------------
|
|
177 |
// MsgServiceViewManager::send
|
|
178 |
// @see header
|
|
179 |
//----------------------------------------------------------------------------
|
|
180 |
void MsgServiceViewManager::send(const QString phoneNumber,
|
|
181 |
const qint32 contactId,
|
|
182 |
const QString displayName)
|
|
183 |
{
|
51
|
184 |
Q_UNUSED(contactId);
|
67
|
185 |
mMainWindow->show();
|
37
|
186 |
ConvergedMessage message;
|
|
187 |
ConvergedMessageAddress address;
|
|
188 |
address.setAddress(phoneNumber);
|
|
189 |
address.setAlias(displayName);
|
|
190 |
message.addToRecipient(address);
|
|
191 |
|
|
192 |
QVariantList param;
|
|
193 |
QByteArray dataArray;
|
|
194 |
QDataStream messageStream(&dataArray,
|
|
195 |
QIODevice::WriteOnly | QIODevice::Append);
|
|
196 |
message.serialize(messageStream);
|
|
197 |
param << dataArray;
|
|
198 |
|
|
199 |
// switch to editor
|
|
200 |
switchToUniEditor(param);
|
|
201 |
|
|
202 |
XQServiceUtil::toBackground(false);
|
|
203 |
}
|
|
204 |
|
|
205 |
//----------------------------------------------------------------------------
|
|
206 |
// MsgServiceViewManager::send
|
|
207 |
// @see header
|
|
208 |
//----------------------------------------------------------------------------
|
|
209 |
void MsgServiceViewManager::send(const QString phoneNumber,
|
|
210 |
const QString alias,
|
|
211 |
const QString bodyText)
|
|
212 |
{
|
67
|
213 |
mMainWindow->show();
|
37
|
214 |
ConvergedMessage message;
|
|
215 |
ConvergedMessageAddress address;
|
|
216 |
address.setAddress(phoneNumber);
|
|
217 |
address.setAlias(alias);
|
|
218 |
message.addToRecipient(address);
|
|
219 |
message.setBodyText(bodyText);
|
|
220 |
|
|
221 |
QVariantList param;
|
|
222 |
QByteArray dataArray;
|
|
223 |
QDataStream messageStream(&dataArray,
|
|
224 |
QIODevice::WriteOnly | QIODevice::Append);
|
|
225 |
message.serialize(messageStream);
|
|
226 |
param << dataArray;
|
|
227 |
|
|
228 |
// switch to editor
|
|
229 |
switchToUniEditor(param);
|
|
230 |
|
|
231 |
XQServiceUtil::toBackground(false);
|
|
232 |
}
|
|
233 |
|
|
234 |
//----------------------------------------------------------------------------
|
|
235 |
// MsgServiceViewManager::send
|
|
236 |
// @see header
|
|
237 |
//----------------------------------------------------------------------------
|
|
238 |
void MsgServiceViewManager::send(const QVariantMap addressList,
|
|
239 |
const QString bodyText)
|
|
240 |
{
|
67
|
241 |
mMainWindow->show();
|
|
242 |
QStringList phoneNumList = addressList.keys();
|
|
243 |
ConvergedMessageAddressList addrList;
|
37
|
244 |
int count = phoneNumList.count();
|
|
245 |
for( int i = 0; i < count; ++ i )
|
|
246 |
{
|
|
247 |
QString phNum = phoneNumList[i];
|
|
248 |
ConvergedMessageAddress* address = new ConvergedMessageAddress(phNum,
|
|
249 |
addressList.value(phNum).toString());
|
|
250 |
addrList.append(address);
|
|
251 |
}
|
|
252 |
|
|
253 |
ConvergedMessage message;
|
|
254 |
message.addToRecipients(addrList);
|
|
255 |
message.setBodyText(bodyText);
|
|
256 |
|
|
257 |
QVariantList param;
|
|
258 |
QByteArray dataArray;
|
|
259 |
QDataStream messageStream(&dataArray,
|
|
260 |
QIODevice::WriteOnly | QIODevice::Append);
|
|
261 |
message.serialize(messageStream);
|
|
262 |
param << dataArray;
|
|
263 |
|
|
264 |
// switch to editor
|
|
265 |
switchToUniEditor(param);
|
|
266 |
|
|
267 |
XQServiceUtil::toBackground(false);
|
|
268 |
}
|
|
269 |
|
|
270 |
//----------------------------------------------------------------------------
|
|
271 |
// MsgServiceViewManager::send
|
|
272 |
// @see header
|
|
273 |
//----------------------------------------------------------------------------
|
|
274 |
void MsgServiceViewManager::send(QVariant data)
|
|
275 |
{
|
67
|
276 |
mMainWindow->show();
|
37
|
277 |
ConvergedMessage message;
|
|
278 |
ConvergedMessageAttachmentList attachmentList;
|
|
279 |
// handle multiple files from sendUI
|
|
280 |
// e.g. contacts can send multiple vcards
|
|
281 |
QStringList receivedFiles = data.toStringList();
|
|
282 |
int recFileCount = receivedFiles.count();
|
|
283 |
for (int i = 0; i < recFileCount; i++) {
|
|
284 |
ConvergedMessageAttachment *attachment =
|
|
285 |
new ConvergedMessageAttachment(receivedFiles.at(i));
|
|
286 |
attachmentList.append(attachment);
|
|
287 |
}
|
|
288 |
message.addAttachments(attachmentList);
|
|
289 |
|
|
290 |
QVariantList param;
|
|
291 |
QByteArray dataArray;
|
|
292 |
QDataStream messageStream(&dataArray,
|
|
293 |
QIODevice::WriteOnly | QIODevice::Append);
|
|
294 |
message.serialize(messageStream);
|
|
295 |
param << dataArray;
|
|
296 |
|
|
297 |
// switch to editor
|
|
298 |
switchToUniEditor(param);
|
|
299 |
|
|
300 |
XQServiceUtil::toBackground(false);
|
|
301 |
}
|
|
302 |
|
|
303 |
//----------------------------------------------------------------------------
|
|
304 |
// MsgServiceViewManager::switchToUniEditor
|
|
305 |
// @see header
|
|
306 |
//----------------------------------------------------------------------------
|
|
307 |
void MsgServiceViewManager::switchToUniEditor(const QVariantList& editorData)
|
67
|
308 |
{
|
37
|
309 |
// construct
|
67
|
310 |
if (!mUniEditor)
|
|
311 |
{
|
|
312 |
mUniEditor = new MsgUnifiedEditorView();
|
|
313 |
mMainWindow->addView(mUniEditor);
|
|
314 |
mUniEditor->setNavigationAction(mBackAction);
|
|
315 |
connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
|
|
316 |
SLOT(switchView(const QVariantList&)));
|
37
|
317 |
}
|
|
318 |
|
|
319 |
// populate
|
|
320 |
mUniEditor->populateContent(editorData);
|
|
321 |
|
|
322 |
// set current view as editor
|
|
323 |
mMainWindow->setCurrentView(mUniEditor);
|
|
324 |
mCurrentView = MsgBaseView::UNIEDITOR;
|
67
|
325 |
}
|
37
|
326 |
|
|
327 |
//----------------------------------------------------------------------------
|
|
328 |
// MsgServiceViewManager::switchToMsgSettings
|
|
329 |
// @see header
|
|
330 |
//----------------------------------------------------------------------------
|
|
331 |
void MsgServiceViewManager::switchToMsgSettings(const QVariantList& data)
|
67
|
332 |
{
|
37
|
333 |
MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
|
|
334 |
|
|
335 |
if (mCurrentView == MsgBaseView::UNIEDITOR)
|
|
336 |
{
|
|
337 |
view = (MsgSettingsView::SettingsView)data.at(2).toInt();
|
|
338 |
}
|
67
|
339 |
|
37
|
340 |
mCurrentView = MsgBaseView::MSGSETTINGS;
|
|
341 |
|
67
|
342 |
if (!mSettingsView)
|
|
343 |
{
|
|
344 |
mSettingsView = new MsgSettingsView(view);
|
|
345 |
mSettingsView->setNavigationAction(mBackAction);
|
|
346 |
mMainWindow->addView(mSettingsView);
|
37
|
347 |
}
|
|
348 |
mMainWindow->setCurrentView(mSettingsView);
|
67
|
349 |
}
|
|
350 |
|
|
351 |
//----------------------------------------------------------------------------
|
|
352 |
// MsgServiceViewManager::showPopup
|
|
353 |
// @see header
|
|
354 |
//----------------------------------------------------------------------------
|
|
355 |
void MsgServiceViewManager::showPopup(const QString& dispText)
|
|
356 |
{
|
|
357 |
HbDeviceMessageBox msgbox;
|
|
358 |
msgbox.setMessageBoxType(HbMessageBox::MessageTypeInformation);
|
|
359 |
msgbox.setText(dispText);
|
|
360 |
msgbox.setAction(NULL, HbDeviceMessageBox::AcceptButtonRole);
|
|
361 |
msgbox.exec();
|
|
362 |
msgbox.close();
|
|
363 |
}
|
37
|
364 |
|
|
365 |
//----------------------------------------------------------------------------
|
|
366 |
// MsgServiceViewManager::view
|
|
367 |
// @see header
|
|
368 |
//----------------------------------------------------------------------------
|
|
369 |
void MsgServiceViewManager::view(int msgId)
|
67
|
370 |
{
|
|
371 |
// Check if the message is present in store
|
|
372 |
if(!mStoreHandler->exists(msgId))
|
37
|
373 |
{
|
67
|
374 |
showPopup(LOC_DELETED_MESSAGE);
|
|
375 |
HbApplication::quit();
|
|
376 |
return;
|
|
377 |
}
|
|
378 |
|
|
379 |
// Check if the given message is locked for viewing
|
|
380 |
if(mStoreHandler->locked(msgId))
|
|
381 |
{
|
|
382 |
// if locked, then show info-note and exit
|
|
383 |
showPopup(LOC_CANNOT_OPEN_MESSAGE);
|
|
384 |
HbApplication::quit();
|
|
385 |
return;
|
|
386 |
}
|
|
387 |
|
|
388 |
// Mark as read and get message type
|
37
|
389 |
int msgType;
|
67
|
390 |
int msgSubType;
|
|
391 |
mStoreHandler->markAsRead(msgId);
|
|
392 |
mStoreHandler->getMsgTypeInfo(msgId,msgType,msgSubType);
|
|
393 |
|
|
394 |
// Open draft message in editor
|
|
395 |
if(mStoreHandler->isDraftMessage(msgId))
|
|
396 |
{
|
|
397 |
handleDraftMsg(msgId,msgType);
|
|
398 |
return;
|
|
399 |
}
|
|
400 |
|
|
401 |
switch (msgType)
|
|
402 |
{
|
37
|
403 |
case ConvergedMessage::Sms:
|
|
404 |
case ConvergedMessage::Mms:
|
67
|
405 |
{
|
|
406 |
if (msgSubType == ConvergedMessage::VCard)
|
37
|
407 |
{
|
67
|
408 |
handleVCardMsg(msgId);
|
37
|
409 |
}
|
67
|
410 |
else
|
37
|
411 |
{
|
67
|
412 |
handleSmsMmsMsg(msgId);
|
37
|
413 |
}
|
|
414 |
break;
|
67
|
415 |
}
|
|
416 |
case ConvergedMessage::MmsNotification:
|
|
417 |
{
|
|
418 |
handleMmsNotification(msgId);
|
|
419 |
break;
|
|
420 |
}
|
|
421 |
case ConvergedMessage::BioMsg:
|
|
422 |
{
|
|
423 |
if (msgSubType == ConvergedMessage::RingingTone)
|
|
424 |
{
|
|
425 |
handleRingtoneMsg(msgId);
|
37
|
426 |
}
|
67
|
427 |
else if (msgSubType == ConvergedMessage::Provisioning)
|
|
428 |
{
|
|
429 |
handleProvisoningMsg(msgId);
|
|
430 |
}
|
|
431 |
else if (msgSubType == ConvergedMessage::VCard)
|
|
432 |
{
|
|
433 |
handleVCardMsg(msgId);
|
|
434 |
}
|
|
435 |
break;
|
|
436 |
}
|
37
|
437 |
case ConvergedMessage::BT:
|
67
|
438 |
{
|
37
|
439 |
handleBTMessage(msgId);
|
|
440 |
break;
|
67
|
441 |
}
|
37
|
442 |
default:
|
67
|
443 |
{
|
|
444 |
// For all remaining unsupported messages, show delete option
|
|
445 |
showPopup(LOC_UNKNOWN_MSG_TYPE);
|
|
446 |
HbApplication::quit();
|
|
447 |
}
|
37
|
448 |
}
|
67
|
449 |
}
|
37
|
450 |
|
|
451 |
// ----------------------------------------------------------------------------
|
62
|
452 |
// MsgServiceViewManager::handleKeyEvent
|
|
453 |
// @see header
|
|
454 |
// ----------------------------------------------------------------------------
|
|
455 |
bool MsgServiceViewManager::handleKeyEvent(int key)
|
|
456 |
{
|
|
457 |
MsgBaseView *baseView = static_cast<MsgBaseView *>(mMainWindow->currentView());
|
|
458 |
bool eventHandled = false;
|
|
459 |
if (baseView) {
|
|
460 |
eventHandled = baseView->handleKeyEvent(key);
|
|
461 |
}
|
|
462 |
return eventHandled;
|
|
463 |
}
|
|
464 |
|
|
465 |
// ----------------------------------------------------------------------------
|
73
|
466 |
// MsgServiceViewManager::saveContentToDraft
|
|
467 |
// @see header
|
|
468 |
// ----------------------------------------------------------------------------
|
|
469 |
void MsgServiceViewManager::saveContentToDraft()
|
|
470 |
{
|
|
471 |
if(mUniEditor)
|
|
472 |
{
|
|
473 |
mUniEditor->saveContentToDrafts();
|
|
474 |
}
|
|
475 |
}
|
|
476 |
|
|
477 |
// ----------------------------------------------------------------------------
|
67
|
478 |
// MsgServiceViewManager::handleDraftMsg
|
|
479 |
// @see header
|
|
480 |
// ----------------------------------------------------------------------------
|
|
481 |
void MsgServiceViewManager::handleDraftMsg(int msgId, int msgType)
|
|
482 |
{
|
|
483 |
// show the splash-screen
|
73
|
484 |
// Note: This causes cancellation of view switching effects
|
67
|
485 |
// HbSplashScreen::start();
|
|
486 |
connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
|
|
487 |
mCurrentView = MsgBaseView::UNIEDITOR;
|
|
488 |
|
|
489 |
// construct editor instance (keep it minimal)
|
|
490 |
if (!mUniEditor)
|
|
491 |
{
|
|
492 |
mUniEditor = new MsgUnifiedEditorView();
|
|
493 |
mMainWindow->addView(mUniEditor);
|
|
494 |
mUniEditor->setNavigationAction(mBackAction);
|
|
495 |
connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
|
|
496 |
SLOT(switchView(const QVariantList&)));
|
|
497 |
}
|
|
498 |
|
|
499 |
// prepare data for unieditor
|
|
500 |
ConvergedMessage message;
|
|
501 |
ConvergedMessageId convergedMsgId = ConvergedMessageId(msgId);
|
|
502 |
message.setMessageType((ConvergedMessage::MessageType) msgType);
|
|
503 |
message.setMessageId(convergedMsgId);
|
|
504 |
QByteArray dataArray;
|
|
505 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
|
|
506 |
message.serialize(messageStream);
|
|
507 |
QVariantList editorData;
|
|
508 |
editorData << dataArray;
|
|
509 |
|
|
510 |
mMainWindow->show();
|
|
511 |
// populate data into editor
|
|
512 |
mUniEditor->openDraftsMessage(editorData);
|
|
513 |
}
|
|
514 |
|
|
515 |
// ----------------------------------------------------------------------------
|
|
516 |
// MsgServiceViewManager::handleVCardMsg
|
|
517 |
// @see header
|
|
518 |
// ----------------------------------------------------------------------------
|
|
519 |
void MsgServiceViewManager::handleVCardMsg(int msgId)
|
|
520 |
{
|
|
521 |
// Extract vCard filepath
|
|
522 |
QString filepath;
|
|
523 |
UniDataModelLoader* pluginLoader = new UniDataModelLoader();
|
|
524 |
UniDataModelPluginInterface* pluginInterface =
|
|
525 |
pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
|
|
526 |
pluginInterface->setMessageId(msgId);
|
|
527 |
|
|
528 |
// Get attachment list
|
|
529 |
UniMessageInfoList attachments = pluginInterface->attachmentList();
|
|
530 |
if(attachments.count() > 0)
|
|
531 |
{
|
|
532 |
filepath = attachments.at(0)->path();
|
|
533 |
}
|
|
534 |
|
|
535 |
// Cleanup
|
|
536 |
foreach(UniMessageInfo* attachmentInfo,attachments)
|
|
537 |
{
|
|
538 |
delete attachmentInfo;
|
|
539 |
}
|
|
540 |
delete pluginLoader;
|
|
541 |
|
|
542 |
// copy private-vCard file to public location for contacts access
|
|
543 |
QDir tempDir;
|
|
544 |
QString sharedFilePath(QDir::toNativeSeparators(tempDir.tempPath()));
|
|
545 |
sharedFilePath.append(QDir::separator());
|
|
546 |
QFileInfo fInfo(filepath);
|
|
547 |
sharedFilePath.append(fInfo.fileName());
|
|
548 |
QFile::copy(filepath, sharedFilePath);
|
|
549 |
|
|
550 |
// Launch vCard viewer service
|
|
551 |
XQApplicationManager appManager;
|
73
|
552 |
XQAiwRequest* request = appManager.create(XQI_CONTACTS_EDIT,
|
|
553 |
XQOP_CONTACTS_EDIT_CREATE_NEW_VCARD,
|
|
554 |
true); //embedded
|
67
|
555 |
if(request)
|
|
556 |
{
|
|
557 |
QList<QVariant> args;
|
|
558 |
args << sharedFilePath;
|
|
559 |
request->setArguments(args);
|
|
560 |
QVariant retValue;
|
|
561 |
bool res = request->send(retValue);
|
|
562 |
delete request;
|
|
563 |
}
|
|
564 |
|
|
565 |
// Delete shared file now
|
|
566 |
QFile::remove(sharedFilePath);
|
|
567 |
HbApplication::quit();
|
|
568 |
}
|
|
569 |
|
|
570 |
// ----------------------------------------------------------------------------
|
37
|
571 |
// MsgServiceViewManager::handleSmsMmsMsg
|
|
572 |
// @see header
|
|
573 |
// ----------------------------------------------------------------------------
|
67
|
574 |
void MsgServiceViewManager::handleSmsMmsMsg(int msgId)
|
38
|
575 |
{
|
67
|
576 |
// show the splash-screen
|
73
|
577 |
// Note: This causes cancellation of view switching effects
|
67
|
578 |
// HbSplashScreen::start();
|
|
579 |
connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
|
|
580 |
mCurrentView = MsgBaseView::UNIVIEWER;
|
|
581 |
|
|
582 |
// construct viewer instance (keep it minimal)
|
|
583 |
if(!mUniViewer)
|
37
|
584 |
{
|
67
|
585 |
mUniViewer = new UnifiedViewer(msgId);
|
|
586 |
mMainWindow->addView(mUniViewer);
|
|
587 |
mUniViewer->setNavigationAction(mBackAction);
|
|
588 |
connect(mUniViewer, SIGNAL(switchView(const QVariantList&)),
|
|
589 |
this, SLOT(switchView(const QVariantList&)));
|
|
590 |
}
|
|
591 |
|
|
592 |
// populate the viewer
|
|
593 |
mUniViewer->populateContent(msgId, true, 1);
|
|
594 |
mMainWindow->show();
|
|
595 |
}
|
|
596 |
|
|
597 |
// ----------------------------------------------------------------------------
|
|
598 |
// MsgServiceViewManager::handleMmsNotification
|
|
599 |
// @see header
|
|
600 |
// ----------------------------------------------------------------------------
|
|
601 |
void MsgServiceViewManager::handleMmsNotification(int msgId)
|
|
602 |
{
|
|
603 |
// set context to current entry
|
|
604 |
if( KErrNone != mStoreHandler->setNotificationMessageId(msgId))
|
|
605 |
{
|
|
606 |
return;
|
|
607 |
}
|
38
|
608 |
|
67
|
609 |
// notification state e.g. waiting, retrieving etc
|
73
|
610 |
QString displayTxt;
|
67
|
611 |
QString statusStr;
|
|
612 |
int status;
|
|
613 |
mStoreHandler->notificationStatus(status, statusStr);
|
|
614 |
if(!statusStr.isEmpty())
|
|
615 |
{
|
73
|
616 |
displayTxt.append(statusStr).append(QChar::LineSeparator);
|
|
617 |
}
|
|
618 |
|
|
619 |
QString sender = mStoreHandler->notificationSender();
|
|
620 |
if(!sender.isEmpty())
|
|
621 |
{
|
|
622 |
displayTxt.append(sender).append(QChar::LineSeparator);
|
|
623 |
}
|
|
624 |
|
|
625 |
QString timestamp = mStoreHandler->notificationTimeStamp();
|
|
626 |
if(!timestamp.isEmpty())
|
|
627 |
{
|
|
628 |
displayTxt.append(timestamp).append(QChar::LineSeparator);
|
|
629 |
}
|
|
630 |
|
|
631 |
QString subject = mStoreHandler->notificationSubject();
|
|
632 |
if(!subject.isEmpty())
|
|
633 |
{
|
|
634 |
displayTxt.append(subject).append(QChar::LineSeparator);
|
|
635 |
}
|
|
636 |
|
|
637 |
QString msgSize = mStoreHandler->notificationMsgSize();
|
|
638 |
if(!msgSize.isEmpty())
|
|
639 |
{
|
|
640 |
displayTxt.append(msgSize).append(QChar::LineSeparator);
|
|
641 |
}
|
|
642 |
|
|
643 |
QString msgClass = mStoreHandler->notificationClass();
|
|
644 |
if(!msgClass.isEmpty())
|
|
645 |
{
|
|
646 |
displayTxt.append(msgClass).append(QChar::LineSeparator);
|
|
647 |
}
|
|
648 |
|
|
649 |
QString exprDate = mStoreHandler->notificationExpiryDate();
|
|
650 |
if(!exprDate.isEmpty())
|
|
651 |
{
|
|
652 |
displayTxt.append(exprDate);
|
|
653 |
}
|
|
654 |
|
|
655 |
HbDeviceMessageBox msgbox;
|
|
656 |
msgbox.setText(displayTxt);
|
|
657 |
msgbox.setDismissPolicy(HbPopup::NoDismiss);
|
|
658 |
msgbox.setTimeout(HbPopup::NoTimeout);
|
|
659 |
msgbox.exec();
|
|
660 |
msgbox.close();
|
67
|
661 |
HbApplication::quit();
|
|
662 |
}
|
38
|
663 |
|
67
|
664 |
// ----------------------------------------------------------------------------
|
|
665 |
// MsgServiceViewManager::showOnViewReady
|
|
666 |
// @see header
|
|
667 |
// ----------------------------------------------------------------------------
|
|
668 |
void MsgServiceViewManager::showOnViewReady()
|
|
669 |
{
|
|
670 |
switch(mCurrentView)
|
|
671 |
{
|
|
672 |
case MsgBaseView::UNIVIEWER:
|
38
|
673 |
{
|
67
|
674 |
mMainWindow->setCurrentView(mUniViewer);
|
|
675 |
break;
|
38
|
676 |
}
|
67
|
677 |
case MsgBaseView::UNIEDITOR:
|
|
678 |
{
|
|
679 |
mMainWindow->setCurrentView(mUniEditor);
|
|
680 |
break;
|
|
681 |
}
|
|
682 |
default:
|
|
683 |
break;
|
37
|
684 |
}
|
67
|
685 |
disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
|
38
|
686 |
}
|
37
|
687 |
|
|
688 |
// ----------------------------------------------------------------------------
|
|
689 |
// MsgServiceViewManager::handleRingtoneMsg
|
|
690 |
// @see header
|
|
691 |
// ----------------------------------------------------------------------------
|
|
692 |
void MsgServiceViewManager::handleRingtoneMsg(int msgId)
|
67
|
693 |
{
|
|
694 |
// Extract rintone filepath
|
|
695 |
UniDataModelLoader* pluginLoader = new UniDataModelLoader();
|
|
696 |
UniDataModelPluginInterface* pluginInterface =
|
|
697 |
pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
|
|
698 |
pluginInterface->setMessageId(msgId);
|
|
699 |
|
|
700 |
// Get attachment list
|
|
701 |
UniMessageInfoList attachments = pluginInterface->attachmentList();
|
|
702 |
QString filepath;
|
|
703 |
if(attachments.count() > 0)
|
37
|
704 |
{
|
67
|
705 |
filepath = attachments.at(0)->path();
|
|
706 |
}
|
|
707 |
|
|
708 |
// Cleanup
|
|
709 |
foreach(UniMessageInfo* attachmentInfo,attachments)
|
|
710 |
{
|
|
711 |
delete attachmentInfo;
|
37
|
712 |
}
|
67
|
713 |
delete pluginLoader;
|
|
714 |
|
|
715 |
RingBc* ringBc = new RingBc();
|
|
716 |
QString filename = ringBc->toneTitle(filepath);
|
73
|
717 |
QString loc_str = LOC_SAVE_RINGTONE.arg(filename);
|
67
|
718 |
bool save = HbDeviceMessageBox::question(loc_str,
|
|
719 |
HbMessageBox::Save | HbMessageBox::Cancel);
|
|
720 |
if(save)
|
|
721 |
{
|
|
722 |
ringBc->saveTone(filepath);
|
|
723 |
}
|
|
724 |
delete ringBc;
|
|
725 |
HbApplication::quit();
|
|
726 |
}
|
37
|
727 |
|
|
728 |
// ----------------------------------------------------------------------------
|
|
729 |
// MsgServiceViewManager::handleProvisoningMsg
|
|
730 |
// @see header
|
|
731 |
// ----------------------------------------------------------------------------
|
|
732 |
void MsgServiceViewManager::handleProvisoningMsg(int msgId)
|
|
733 |
{
|
|
734 |
QString messageId;
|
|
735 |
messageId.setNum(msgId);
|
|
736 |
|
|
737 |
XQApplicationManager* aiwMgr = new XQApplicationManager();
|
|
738 |
|
|
739 |
XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM",
|
|
740 |
"Provisioning",
|
|
741 |
"ProcessMessage(QString)", true); // embedded
|
|
742 |
|
|
743 |
if (request) {
|
|
744 |
QList<QVariant> args;
|
|
745 |
args << QVariant(messageId);
|
|
746 |
request->setArguments(args);
|
|
747 |
|
|
748 |
// Send the request
|
|
749 |
bool res = request->send();
|
|
750 |
|
|
751 |
// Cleanup
|
|
752 |
delete request;
|
|
753 |
}
|
|
754 |
|
|
755 |
delete aiwMgr;
|
|
756 |
|
|
757 |
// close the application once its handled
|
|
758 |
HbApplication::quit();
|
|
759 |
}
|
|
760 |
|
|
761 |
//-----------------------------------------------------------------------------
|
|
762 |
//MsgServiceViewManager::handleBTMessage()
|
|
763 |
//@see header
|
|
764 |
//-----------------------------------------------------------------------------
|
|
765 |
void MsgServiceViewManager::handleBTMessage(int msgId)
|
|
766 |
{
|
|
767 |
XQApplicationManager* aiwMgr = new XQApplicationManager();
|
|
768 |
XQAiwRequest* request =
|
|
769 |
aiwMgr->create("com.nokia.services.btmsgdispservices", "displaymsg",
|
|
770 |
"displaymsg(int)", true); // embedded
|
|
771 |
|
|
772 |
if (request) {
|
|
773 |
QList<QVariant> args;
|
|
774 |
args << QVariant(msgId);
|
|
775 |
request->setArguments(args);
|
|
776 |
|
|
777 |
// Send the request
|
|
778 |
bool res = request->send();
|
|
779 |
|
|
780 |
// Cleanup
|
|
781 |
delete request;
|
|
782 |
}
|
|
783 |
|
|
784 |
delete aiwMgr;
|
|
785 |
|
|
786 |
// close the application once its handled
|
|
787 |
HbApplication::quit();
|
|
788 |
}
|
|
789 |
|
|
790 |
//-----------------------------------------------------------------------------
|
51
|
791 |
//MsgServiceViewManager::startAnimation
|
|
792 |
//@see header
|
|
793 |
//-----------------------------------------------------------------------------
|
|
794 |
void MsgServiceViewManager::startAnimation(QString effectEvent)
|
|
795 |
{
|
|
796 |
// take screen shot
|
|
797 |
QGraphicsPixmapItem *animationScreenShot = screenShot();
|
|
798 |
if (animationScreenShot)
|
|
799 |
{
|
|
800 |
// but don't show it yet.
|
|
801 |
animationScreenShot->hide();
|
|
802 |
animationScreenShot->setPos(0,0);
|
|
803 |
animationScreenShot->setZValue(0);
|
|
804 |
|
|
805 |
// hide items, so that background app's items are visible immediately
|
|
806 |
mMainWindow->currentView()->hideItems(Hb::AllItems);
|
|
807 |
|
|
808 |
// reset background & set the base transparent
|
|
809 |
mMainWindow->setBackgroundImageName(
|
|
810 |
mMainWindow->orientation(), QString("dummy_blank"));
|
|
811 |
QPalette p = mMainWindow->viewport()->palette();
|
|
812 |
p.setColor(QPalette::Base, Qt::transparent);
|
|
813 |
mMainWindow->viewport()->setPalette(p);
|
|
814 |
|
|
815 |
// add animating item directly to the scene
|
|
816 |
mMainWindow->scene()->addItem(animationScreenShot);
|
|
817 |
|
|
818 |
// hide other views
|
|
819 |
QList<HbView*> vws = mMainWindow->views();
|
|
820 |
while (!vws.isEmpty())
|
|
821 |
{
|
|
822 |
HbView* view = vws.takeLast();
|
|
823 |
view->hide();
|
|
824 |
}
|
|
825 |
|
|
826 |
// now show the animating item, and start animation on it
|
|
827 |
animationScreenShot->show();
|
|
828 |
QString effectFile = getAnimationFile(effectEvent);
|
|
829 |
HbEffect::add(animationScreenShot, effectFile, effectEvent);
|
|
830 |
HbEffect::start(animationScreenShot, effectEvent, this,
|
|
831 |
"onAnimationComplete");
|
|
832 |
}
|
|
833 |
}
|
|
834 |
|
|
835 |
//-----------------------------------------------------------------------------
|
|
836 |
//MsgServiceViewManager::resetAnimation
|
|
837 |
//@see header
|
|
838 |
//-----------------------------------------------------------------------------
|
|
839 |
void MsgServiceViewManager::resetAnimation(
|
|
840 |
QString effectEvent,
|
|
841 |
QGraphicsItem* item)
|
|
842 |
{
|
|
843 |
if (item)
|
|
844 |
{
|
|
845 |
QString effectFile = getAnimationFile(effectEvent);
|
|
846 |
HbEffect::remove(item, effectFile, effectEvent);
|
|
847 |
mMainWindow->scene()->removeItem(item);
|
|
848 |
delete item;
|
|
849 |
item = NULL;
|
|
850 |
}
|
|
851 |
}
|
|
852 |
|
|
853 |
//-----------------------------------------------------------------------------
|
|
854 |
//MsgServiceViewManager::onAnimationComplete
|
|
855 |
//@see header
|
|
856 |
//-----------------------------------------------------------------------------
|
|
857 |
void MsgServiceViewManager::onAnimationComplete(
|
|
858 |
const HbEffect::EffectStatus &status)
|
|
859 |
{
|
|
860 |
QGraphicsItem* item = status.item;
|
|
861 |
QString effectEvent = status.effectEvent;
|
|
862 |
resetAnimation(effectEvent, item);
|
|
863 |
HbApplication::quit();
|
|
864 |
}
|
|
865 |
|
|
866 |
//-----------------------------------------------------------------------------
|
|
867 |
//MsgServiceViewManager::screenShot
|
|
868 |
//@see header
|
|
869 |
//-----------------------------------------------------------------------------
|
|
870 |
QGraphicsPixmapItem* MsgServiceViewManager::screenShot()
|
|
871 |
{
|
|
872 |
// set fullscreen and hide unwanted items
|
|
873 |
mMainWindow->currentView()->hideItems(Hb::ToolBarItem | Hb::DockWidgetItem | Hb::StatusBarItem);
|
|
874 |
mMainWindow->currentView()->setContentFullScreen(true);
|
|
875 |
|
|
876 |
// grab whole view into pixmap image
|
|
877 |
QPixmap screenCapture = QPixmap::grabWindow(mMainWindow->internalWinId());
|
|
878 |
|
|
879 |
// create an QGraphicsItem to do animation
|
|
880 |
QGraphicsPixmapItem *ret(NULL);
|
|
881 |
|
|
882 |
// for landscape, the screenshot must be rotated
|
|
883 |
if(mMainWindow->orientation() == Qt::Horizontal)
|
|
884 |
{
|
|
885 |
QMatrix mat;
|
|
886 |
mat.rotate(-90); // rotate 90 degrees counter-clockwise
|
|
887 |
ret = new QGraphicsPixmapItem(screenCapture.transformed(mat));
|
|
888 |
}
|
|
889 |
else
|
|
890 |
{
|
|
891 |
ret = new QGraphicsPixmapItem(screenCapture);
|
|
892 |
}
|
|
893 |
return ret;
|
|
894 |
}
|
|
895 |
|
|
896 |
//-----------------------------------------------------------------------------
|
|
897 |
//MsgServiceViewManager::getAnimationFile
|
|
898 |
//@see header
|
|
899 |
//-----------------------------------------------------------------------------
|
|
900 |
QString MsgServiceViewManager::getAnimationFile(QString effectEvent)
|
|
901 |
{
|
|
902 |
QString animFile;
|
|
903 |
if(effectEvent == SEND_EFFECT)
|
|
904 |
{
|
|
905 |
animFile.append(SEND_EFFECT_FILE);
|
|
906 |
}
|
|
907 |
|
|
908 |
return animFile;
|
|
909 |
}
|
56
|
910 |
|
|
911 |
//-----------------------------------------------------------------------------
|
|
912 |
//MsgServiceViewManager::send
|
|
913 |
//@see header
|
|
914 |
//-----------------------------------------------------------------------------
|
|
915 |
|
|
916 |
void MsgServiceViewManager::send(ConvergedMessage message)
|
|
917 |
{
|
67
|
918 |
mMainWindow->show();
|
56
|
919 |
QVariantList param;
|
|
920 |
QByteArray dataArray;
|
|
921 |
QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
|
|
922 |
message.serialize(messageStream);
|
|
923 |
param << dataArray;
|
|
924 |
|
|
925 |
// switch to editor
|
|
926 |
switchToUniEditor(param);
|
|
927 |
|
|
928 |
XQServiceUtil::toBackground(false);
|
|
929 |
}
|
|
930 |
|
|
931 |
|
|
932 |
|