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 |
// SYSTEM INCLUDES
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <HbMenu>
|
|
21 |
#include <HbAction>
|
|
22 |
#include <HbToolBar>
|
|
23 |
#include <QGraphicsLinearLayout>
|
|
24 |
#include <HbGroupBox>
|
|
25 |
#include <HbScrollArea>
|
|
26 |
#include <QDateTime>
|
|
27 |
#include <QDir>
|
|
28 |
#include <QBuffer>
|
|
29 |
#include <QFile>
|
|
30 |
#include <QFileInfo>
|
|
31 |
#include <xqconversions.h>
|
|
32 |
#include <HbToolBarExtension>
|
|
33 |
#include <HbListWidget>
|
|
34 |
#include <HbFrameBackground>
|
|
35 |
#include <HbListViewItem>
|
|
36 |
#include <HbListWidgetItem>
|
|
37 |
#include <HbNotificationDialog>
|
|
38 |
#include <HbMessageBox>
|
|
39 |
#include <HbAbstractVkbHost>
|
|
40 |
#include <HbMainWindow>
|
|
41 |
#include <xqaiwrequest.h>
|
|
42 |
#include <xqappmgr.h>
|
|
43 |
#include <HbStyleLoader>
|
|
44 |
// QT Mobility for fetching business card
|
|
45 |
#include <qmobilityglobal.h>
|
|
46 |
#include <qversitwriter.h>
|
|
47 |
#include <qversitdocument.h>
|
|
48 |
#include <qcontact.h>
|
|
49 |
#include <qcontactmanager.h>
|
|
50 |
#include <qversitcontactexporter.h>
|
|
51 |
#include <cntservicescontact.h>
|
|
52 |
|
|
53 |
|
|
54 |
// USER INCLUDES
|
|
55 |
#include "debugtraces.h"
|
|
56 |
#include "msgunieditorview.h"
|
|
57 |
#include "msgunieditoraddress.h"
|
|
58 |
#include "msgunieditorsubject.h"
|
|
59 |
#include "msgunieditorbody.h"
|
|
60 |
#include "msgmonitor.h"
|
|
61 |
#include "msgattachmentcontainer.h"
|
|
62 |
#include "msgsendutil.h"
|
|
63 |
#include "convergedmessageaddress.h"
|
|
64 |
#include "unieditorgenutils.h"
|
|
65 |
#include "unieditorpluginloader.h"
|
|
66 |
#include "unieditorplugininterface.h"
|
|
67 |
#include "msgsettingsview.h"
|
|
68 |
|
|
69 |
QTM_USE_NAMESPACE
|
|
70 |
// Constants
|
|
71 |
const QString SEND_ICON("qtg_mono_send");
|
|
72 |
const QString ATTACH_ICON("qtg_mono_attach");
|
|
73 |
// temporary folder for unieditor
|
|
74 |
const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor");
|
|
75 |
|
|
76 |
const int INVALID_MSGID = -1;
|
|
77 |
// vcard file extn.
|
|
78 |
const QString FILE_EXTN(".vcf");
|
|
79 |
// Max vcards inside a msg. Using a very large number.
|
|
80 |
// TODO: how we can avoid this?
|
|
81 |
const int MAX_VCARDS(1000);
|
|
82 |
|
|
83 |
// LOCALIZED CONSTANTS
|
|
84 |
//To,Cc.Bcc
|
|
85 |
#define LOC_TO hbTrId("txt_messaging_formlabel_to")
|
|
86 |
#define LOC_CC hbTrId("txt_messaging_formlabel_cc")
|
|
87 |
#define LOC_BCC hbTrId("txt_messaging_formlabel_bcc")
|
|
88 |
|
|
89 |
//attach options
|
|
90 |
#define LOC_PHOTO hbTrId("txt_messaging_button_photo")
|
|
91 |
#define LOC_SOUND hbTrId("txt_messaging_button_sound")
|
|
92 |
#define LOC_BUSINESS_CARD hbTrId("txt_messaging_button_business_card")
|
|
93 |
|
|
94 |
//options menu.
|
|
95 |
#define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject")
|
|
96 |
#define LOC_ADD_CC_BCC hbTrId("txt_messaging_opt_add_cc_bcc")
|
|
97 |
#define LOC_PRIORITY hbTrId("txt_messaging_setlabel_priority")
|
|
98 |
#define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options")
|
|
99 |
#define LOC_DELETE_MESSAGE hbTrId("txt_messaging_opt_delete_message")
|
|
100 |
|
|
101 |
//priority sub menu
|
|
102 |
#define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high")
|
|
103 |
#define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal")
|
|
104 |
#define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low")
|
|
105 |
|
|
106 |
//group box
|
|
107 |
#define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
|
|
108 |
|
|
109 |
//saved to draft note
|
|
110 |
#define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
|
|
111 |
|
|
112 |
//delete confermation
|
|
113 |
#define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
|
|
114 |
#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
|
|
115 |
#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
|
|
116 |
#define LOC_DIALOG_OK hbTrId("txt_common_button_ok")
|
|
117 |
|
|
118 |
// attachment addition failure note
|
|
119 |
#define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
|
|
120 |
|
|
121 |
//extension list item frame.
|
|
122 |
const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
|
|
123 |
|
|
124 |
//settings confirmation
|
|
125 |
#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
|
|
126 |
#define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_settings_incomplete")
|
|
127 |
// LOCAL FUNCTIONS
|
|
128 |
|
|
129 |
//---------------------------------------------------------------
|
|
130 |
// editorTempPath
|
|
131 |
// @return fullPath of unified editor's temporary dir
|
|
132 |
//---------------------------------------------------------------
|
|
133 |
QString editorTempPath()
|
|
134 |
{
|
|
135 |
QDir tempDir;
|
|
136 |
QString tempPath(QDir::toNativeSeparators(tempDir.tempPath()));
|
|
137 |
tempPath.append(QDir::separator());
|
|
138 |
tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER);
|
|
139 |
tempPath.append(QDir::separator());
|
|
140 |
return tempPath;
|
|
141 |
}
|
|
142 |
|
|
143 |
//---------------------------------------------------------------
|
|
144 |
// MsgUnifiedEditorView::MsgUnifiedEditorView
|
|
145 |
// @see header file
|
|
146 |
//---------------------------------------------------------------
|
|
147 |
MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
|
|
148 |
MsgBaseView(parent),
|
|
149 |
mSubjectAction(0),
|
|
150 |
mCcBccAction(0),
|
|
151 |
mMainLayout(0),
|
|
152 |
mSubjectField(0),
|
|
153 |
mToField(0),
|
|
154 |
mCcField(0),
|
|
155 |
mBccField(0),
|
|
156 |
mBody(0),
|
|
157 |
mContentWidget(0),
|
|
158 |
mMsgMonitor(0),
|
|
159 |
mAttachmentContainer(0),
|
|
160 |
mPluginLoader(0),
|
|
161 |
mCanSaveToDrafts(true),
|
|
162 |
mVkbHost(NULL)
|
|
163 |
{
|
|
164 |
connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
|
|
165 |
|
|
166 |
addToolBar();
|
|
167 |
initView();
|
|
168 |
}
|
|
169 |
|
|
170 |
//---------------------------------------------------------------
|
|
171 |
// MsgUnifiedEditorView::~MsgUnifiedEditorView
|
|
172 |
// @see header file
|
|
173 |
//---------------------------------------------------------------
|
|
174 |
MsgUnifiedEditorView::~MsgUnifiedEditorView()
|
|
175 |
{
|
|
176 |
// clean editor's temporary contents before exiting
|
|
177 |
removeTempFolder();
|
|
178 |
}
|
|
179 |
|
|
180 |
//---------------------------------------------------------------
|
|
181 |
// MsgUnifiedEditorView::initView
|
|
182 |
// @see header file
|
|
183 |
//---------------------------------------------------------------
|
|
184 |
void MsgUnifiedEditorView::initView()
|
|
185 |
{
|
|
186 |
if (!HbStyleLoader::registerFilePath(":/layouts")) {
|
|
187 |
QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath");
|
|
188 |
}
|
|
189 |
HbScrollArea* scrollArea = new HbScrollArea(this);
|
|
190 |
this->setWidget(scrollArea);
|
|
191 |
|
|
192 |
mContentWidget = new HbWidget(this);
|
|
193 |
scrollArea->setContentWidget(mContentWidget);
|
|
194 |
|
|
195 |
mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget);
|
|
196 |
qreal vTopSpacing = 0.0;
|
|
197 |
qreal vItemSpacing = 0.0;
|
|
198 |
style()->parameter("hb-param-margin-gene-top",vTopSpacing);
|
|
199 |
style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
|
|
200 |
|
|
201 |
mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
|
|
202 |
mMainLayout->setSpacing(vItemSpacing);
|
|
203 |
|
|
204 |
mMsgMonitor = new MsgMonitor(this);
|
|
205 |
|
|
206 |
mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
|
|
207 |
|
|
208 |
mBody = new MsgUnifiedEditorBody( mContentWidget);
|
|
209 |
|
|
210 |
mMainLayout->addItem(mToField);
|
|
211 |
mMainLayout->addItem(mBody);
|
|
212 |
|
|
213 |
//Set the invalid msg id
|
|
214 |
mOpenedMessageId.setId(-1);
|
|
215 |
|
|
216 |
connect(mToField, SIGNAL(sendMessage()), this, SLOT(send()));
|
|
217 |
connect(mToField, SIGNAL(contentChanged()),
|
|
218 |
mMsgMonitor, SLOT(handleContentChange()));
|
|
219 |
connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
|
|
220 |
|
|
221 |
connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
|
|
222 |
connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
|
|
223 |
connect(mBody, SIGNAL(contentChanged()),
|
|
224 |
mMsgMonitor, SLOT(handleContentChange()));
|
|
225 |
|
|
226 |
}
|
|
227 |
|
|
228 |
void MsgUnifiedEditorView::addMenu()
|
|
229 |
{
|
|
230 |
//Create Menu Options
|
|
231 |
HbMenu* mainMenu = new HbMenu();
|
|
232 |
mainMenu->setFocusPolicy(Qt::NoFocus);
|
|
233 |
|
|
234 |
//if subject field / cc,bcc fields are already present don't add corresponding actions.
|
|
235 |
if(!mSubjectField)
|
|
236 |
{
|
|
237 |
mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT);
|
|
238 |
}
|
|
239 |
|
|
240 |
if(!mCcField)
|
|
241 |
{
|
|
242 |
mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC);
|
|
243 |
}
|
|
244 |
|
|
245 |
HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY);
|
|
246 |
|
|
247 |
HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH);
|
|
248 |
highPriorityAction->setData(ConvergedMessage::High);
|
|
249 |
|
|
250 |
HbAction* normalPriorityAction = prioritySubMenu->addAction(LOC_NORMAL);
|
|
251 |
normalPriorityAction->setData(ConvergedMessage::Normal);
|
|
252 |
|
|
253 |
HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
|
|
254 |
lowPriorityAction->setData(ConvergedMessage::Low);
|
|
255 |
|
|
256 |
HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS);
|
|
257 |
HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
|
|
258 |
|
|
259 |
connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
|
|
260 |
connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
|
|
261 |
connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
|
|
262 |
connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
|
|
263 |
connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
|
|
264 |
connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions()));
|
|
265 |
connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
|
|
266 |
|
|
267 |
setMenu(mainMenu);
|
|
268 |
}
|
|
269 |
|
|
270 |
void MsgUnifiedEditorView::openDraftsMessage(const QVariantList& editorData)
|
|
271 |
{
|
|
272 |
// unpack editor's data
|
|
273 |
// first arg is convergedmessage
|
|
274 |
QByteArray dataArray = editorData.at(0).toByteArray();
|
|
275 |
ConvergedMessage* messageDetails = new ConvergedMessage;
|
|
276 |
QDataStream stream(&dataArray, QIODevice::ReadOnly);
|
|
277 |
messageDetails->deserialize(stream);
|
|
278 |
ConvergedMessage::MessageType messageType = messageDetails->messageType();
|
|
279 |
ConvergedMessageId messageId = *(messageDetails->id());
|
|
280 |
delete messageDetails;
|
|
281 |
|
|
282 |
if(!mPluginLoader)
|
|
283 |
{
|
|
284 |
mPluginLoader = new UniEditorPluginLoader(this);
|
|
285 |
}
|
|
286 |
|
|
287 |
UniEditorPluginInterface* pluginInterface =
|
|
288 |
mPluginLoader->getUniEditorPlugin(messageType);
|
|
289 |
|
|
290 |
mOpenedMessageId.setId(messageId.getId());
|
|
291 |
mmOpenedMessageType = messageType;
|
|
292 |
|
|
293 |
//Fetch the converged message from the msgId
|
|
294 |
ConvergedMessage* msg;
|
|
295 |
msg = pluginInterface->convertFrom(messageId.getId());
|
|
296 |
|
|
297 |
if( msg != NULL )
|
|
298 |
{
|
|
299 |
//Populate the content inside editor
|
|
300 |
populateContentIntoEditor(*msg);
|
|
301 |
delete msg;
|
|
302 |
}
|
|
303 |
|
|
304 |
mCanSaveToDrafts = false;
|
|
305 |
}
|
|
306 |
|
|
307 |
void MsgUnifiedEditorView::forwardMessage(ConvergedMessageId& messageId,
|
|
308 |
ConvergedMessage::MessageType messageType )
|
|
309 |
{
|
|
310 |
if(!mPluginLoader)
|
|
311 |
{
|
|
312 |
mPluginLoader = new UniEditorPluginLoader(this);
|
|
313 |
|
|
314 |
}
|
|
315 |
UniEditorPluginInterface* pluginInterface = NULL;
|
|
316 |
if( messageType == ConvergedMessage::Mms )
|
|
317 |
{
|
|
318 |
pluginInterface =
|
|
319 |
mPluginLoader->getUniEditorPlugin(ConvergedMessage::Mms);
|
|
320 |
}
|
|
321 |
else // For sms,vcard,vcal cases
|
|
322 |
{
|
|
323 |
pluginInterface =
|
|
324 |
mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms);
|
|
325 |
}
|
|
326 |
|
|
327 |
//Fetch the converged message from the msgId
|
|
328 |
ConvergedMessage* msg;
|
|
329 |
msg = pluginInterface->convertFrom(messageId.getId(),
|
|
330 |
UniEditorPluginInterface::Forward);
|
|
331 |
|
|
332 |
if( msg != NULL )
|
|
333 |
{
|
|
334 |
//Populate the content inside editor
|
|
335 |
populateContentIntoEditor(*msg);
|
|
336 |
delete msg;
|
|
337 |
}
|
|
338 |
}
|
|
339 |
|
|
340 |
void MsgUnifiedEditorView::populateContent(const QVariantList& editorData)
|
|
341 |
{
|
|
342 |
// unpack editor's data
|
|
343 |
// first arg is convergedmessage
|
|
344 |
QByteArray dataArray = editorData.at(0).toByteArray();
|
|
345 |
ConvergedMessage* messageDetails = new ConvergedMessage;
|
|
346 |
QDataStream stream(&dataArray, QIODevice::ReadOnly);
|
|
347 |
messageDetails->deserialize(stream);
|
|
348 |
|
|
349 |
// get next arg i.e. editor operation command
|
|
350 |
int editorOp = 0;
|
|
351 |
if(editorData.length() > 1)
|
|
352 |
{
|
|
353 |
editorOp = editorData.at(1).toInt();
|
|
354 |
}
|
|
355 |
|
|
356 |
// population logic based on editor Operation command
|
|
357 |
switch(editorOp)
|
|
358 |
{
|
|
359 |
case MsgBaseView::ADD_SUBJECT:
|
|
360 |
{
|
|
361 |
addSubject();
|
|
362 |
setFocus(mSubjectField);
|
|
363 |
}
|
|
364 |
break;
|
|
365 |
case MsgBaseView::ADD_VCARD:
|
|
366 |
{
|
|
367 |
contactsFetched(editorData.at(2));
|
|
368 |
}
|
|
369 |
break;
|
|
370 |
case MsgBaseView::FORWARD_MSG:
|
|
371 |
{
|
|
372 |
forwardMessage(*messageDetails->id(), messageDetails->messageType());
|
|
373 |
}
|
|
374 |
break;
|
|
375 |
default:
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
|
|
379 |
// additional common operations for non-forwarded messages
|
|
380 |
if(editorOp != MsgBaseView::FORWARD_MSG)
|
|
381 |
{
|
|
382 |
if(editorOp == MsgBaseView::ADD_RECIPIENTS)
|
|
383 |
{
|
|
384 |
// CV sends contact card address as the first address
|
|
385 |
ConvergedMessageAddressList toAddresses =
|
|
386 |
messageDetails->toAddressList();
|
|
387 |
int addrCount = toAddresses.count();
|
|
388 |
if(addrCount > 0)
|
|
389 |
{
|
|
390 |
// add contact card address first
|
|
391 |
ConvergedMessageAddress *firstAddress =
|
|
392 |
new ConvergedMessageAddress();
|
|
393 |
firstAddress->setAlias(toAddresses.at(0)->alias());
|
|
394 |
firstAddress->setAddress(toAddresses.at(0)->address());
|
|
395 |
ConvergedMessageAddressList firstList;
|
|
396 |
firstList << firstAddress;
|
|
397 |
mToField->setAddresses(firstList);
|
|
398 |
|
|
399 |
// add remaining contacts now
|
|
400 |
ConvergedMessageAddressList otherList;
|
|
401 |
for(int i=1; i<addrCount; i++)
|
|
402 |
{
|
|
403 |
otherList << toAddresses.at(i);
|
|
404 |
}
|
|
405 |
mToField->setAddresses(otherList);
|
|
406 |
}
|
|
407 |
}
|
|
408 |
else
|
|
409 |
{
|
|
410 |
mToField->setAddresses(messageDetails->toAddressList());
|
|
411 |
}
|
|
412 |
QString bodyTxt = messageDetails->bodyText();
|
|
413 |
mBody->setText(bodyTxt);
|
|
414 |
|
|
415 |
int attachmentCount = messageDetails->attachments().count();
|
|
416 |
QStringList pendingAttList;
|
|
417 |
for(int i=0; i<attachmentCount; i++)
|
|
418 |
{
|
|
419 |
int imageSize=0;
|
|
420 |
QString mimeType;
|
|
421 |
TMsgMediaType mediaType = EMsgMediaUnknown;
|
|
422 |
QString filePath = messageDetails->attachments().at(i)->filePath();
|
|
423 |
UniEditorGenUtils* genUtils = new UniEditorGenUtils;
|
|
424 |
TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
|
|
425 |
mimeType,mediaType));
|
|
426 |
delete genUtils;
|
|
427 |
switch(mediaType)
|
|
428 |
{
|
|
429 |
case EMsgMediaImage:
|
|
430 |
{
|
|
431 |
mBody->setImage(filePath);
|
|
432 |
}
|
|
433 |
break;
|
|
434 |
case EMsgMediaAudio:
|
|
435 |
{
|
|
436 |
mBody->setAudio(filePath);
|
|
437 |
}
|
|
438 |
break;
|
|
439 |
default:
|
|
440 |
{
|
|
441 |
pendingAttList << filePath;
|
|
442 |
}
|
|
443 |
break;
|
|
444 |
}
|
|
445 |
}
|
|
446 |
// add pending attachments in bulk
|
|
447 |
addAttachments(pendingAttList);
|
|
448 |
}
|
|
449 |
delete messageDetails;
|
|
450 |
}
|
|
451 |
|
|
452 |
void MsgUnifiedEditorView::populateContentIntoEditor(
|
|
453 |
const ConvergedMessage& messageDetails)
|
|
454 |
{
|
|
455 |
// skip first-time MMS type switch note for draft
|
|
456 |
mMsgMonitor->setSkipNote(true);
|
|
457 |
mToField->skipMaxRecipientQuery(true);
|
|
458 |
|
|
459 |
mToField->setAddresses(messageDetails.toAddressList());
|
|
460 |
if(messageDetails.ccAddressList().count() > 0 )
|
|
461 |
{
|
|
462 |
if(!mCcField)
|
|
463 |
{
|
|
464 |
addCcBcc();
|
|
465 |
}
|
|
466 |
mCcField->setAddresses(messageDetails.ccAddressList());
|
|
467 |
}
|
|
468 |
if(messageDetails.bccAddressList().count() > 0 )
|
|
469 |
{
|
|
470 |
if(!mBccField)
|
|
471 |
{
|
|
472 |
addCcBcc();
|
|
473 |
}
|
|
474 |
mBccField->setAddresses(messageDetails.bccAddressList());
|
|
475 |
}
|
|
476 |
if(messageDetails.subject().size() > 0)
|
|
477 |
{
|
|
478 |
if(!mSubjectField)
|
|
479 |
{
|
|
480 |
addSubject();
|
|
481 |
}
|
|
482 |
mSubjectField->setText(messageDetails.subject());
|
|
483 |
}
|
|
484 |
|
|
485 |
if(messageDetails.priority()==ConvergedMessage::High ||
|
|
486 |
messageDetails.priority() == ConvergedMessage::Low)
|
|
487 |
{
|
|
488 |
if(!mSubjectField)
|
|
489 |
{
|
|
490 |
addSubject();
|
|
491 |
}
|
|
492 |
mSubjectField->setPriority(messageDetails.priority());
|
|
493 |
}
|
|
494 |
|
|
495 |
QString bodyTxt = messageDetails.bodyText();
|
|
496 |
mBody->setText(bodyTxt);
|
|
497 |
|
|
498 |
ConvergedMessageAttachmentList attachmentList =
|
|
499 |
messageDetails.attachments();
|
|
500 |
int attachmentCount = attachmentList.count();
|
|
501 |
|
|
502 |
UniEditorGenUtils* genUtils = new UniEditorGenUtils;
|
|
503 |
|
|
504 |
QStringList pendingAttList;
|
|
505 |
for( int i=0; i < attachmentCount; i++ )
|
|
506 |
{
|
|
507 |
QString filePath = messageDetails.attachments().at(i)->filePath();
|
|
508 |
|
|
509 |
if(attachmentList.at(i)->attachmentType() ==
|
|
510 |
ConvergedMessageAttachment::EInline)
|
|
511 |
{
|
|
512 |
int imageSize=0;
|
|
513 |
QString mimeType;
|
|
514 |
TMsgMediaType mediaType = EMsgMediaUnknown;
|
|
515 |
TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
|
|
516 |
mimeType,mediaType));
|
|
517 |
|
|
518 |
switch(mediaType)
|
|
519 |
{
|
|
520 |
case EMsgMediaImage:
|
|
521 |
{
|
|
522 |
mBody->setImage(filePath);
|
|
523 |
break;
|
|
524 |
}
|
|
525 |
case EMsgMediaAudio:
|
|
526 |
{
|
|
527 |
mBody->setAudio(filePath);
|
|
528 |
break;
|
|
529 |
}
|
|
530 |
default:
|
|
531 |
{
|
|
532 |
pendingAttList << filePath;
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
}
|
|
536 |
}
|
|
537 |
else
|
|
538 |
{
|
|
539 |
pendingAttList << filePath;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
// add pending attachments to editor
|
|
543 |
addAttachments(pendingAttList);
|
|
544 |
|
|
545 |
delete genUtils;
|
|
546 |
// ensure that any msg-type change after this are shown
|
|
547 |
mToField->skipMaxRecipientQuery(false);
|
|
548 |
mMsgMonitor->setSkipNote(false);
|
|
549 |
}
|
|
550 |
|
|
551 |
void MsgUnifiedEditorView::addToolBar()
|
|
552 |
{
|
|
553 |
//Create Tool Bar
|
|
554 |
HbToolBar *toolBar = new HbToolBar();
|
|
555 |
toolBar->setOrientation(Qt::Horizontal);
|
|
556 |
|
|
557 |
//tool bar extension for attach action.
|
|
558 |
HbToolBarExtension* attachExtension = new HbToolBarExtension();
|
|
559 |
HbAction *attachAction = toolBar->addExtension(attachExtension);
|
|
560 |
attachAction->setIcon(HbIcon(ATTACH_ICON));
|
|
561 |
|
|
562 |
mTBExtnContentWidget = new HbListWidget();
|
|
563 |
mTBExtnContentWidget->addItem(LOC_PHOTO);
|
|
564 |
mTBExtnContentWidget->addItem(LOC_SOUND);
|
|
565 |
mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
|
|
566 |
|
|
567 |
HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype();
|
|
568 |
HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces);
|
|
569 |
prototype->setDefaultFrame(frame);
|
|
570 |
|
|
571 |
connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
|
|
572 |
this, SLOT(handleViewExtnActivated(HbListWidgetItem*)));
|
|
573 |
connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
|
|
574 |
attachExtension, SLOT(close()));
|
|
575 |
|
|
576 |
attachExtension->setContentWidget(mTBExtnContentWidget);
|
|
577 |
|
|
578 |
//Add Action to the toolbar and show toolbar
|
|
579 |
toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
|
|
580 |
|
|
581 |
|
|
582 |
setToolBar(toolBar);
|
|
583 |
}
|
|
584 |
|
|
585 |
void MsgUnifiedEditorView::addSubject()
|
|
586 |
{
|
|
587 |
if(mSubjectField)
|
|
588 |
{ // do nothing if already present
|
|
589 |
return;
|
|
590 |
}
|
|
591 |
|
|
592 |
int index =0;
|
|
593 |
int offset = 1;
|
|
594 |
if(mAttachmentContainer)
|
|
595 |
{
|
|
596 |
++offset;
|
|
597 |
}
|
|
598 |
index = mMainLayout->count() - offset;
|
|
599 |
|
|
600 |
mSubjectField = new MsgUnifiedEditorSubject( mContentWidget);
|
|
601 |
|
|
602 |
mMainLayout->insertItem(index,mSubjectField);
|
|
603 |
connect(mSubjectField, SIGNAL(contentChanged()),
|
|
604 |
mMsgMonitor, SLOT(handleContentChange()));
|
|
605 |
connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
|
|
606 |
|
|
607 |
//set focus to subject field.
|
|
608 |
HbAction* subjectAction = qobject_cast<HbAction*>(this->sender());
|
|
609 |
if(subjectAction)
|
|
610 |
{
|
|
611 |
setFocus(mSubjectField);
|
|
612 |
}
|
|
613 |
|
|
614 |
// remove mainmenu's "Add Subject" action
|
|
615 |
if(mSubjectAction)
|
|
616 |
{
|
|
617 |
HbMenu* mainMenu = this->menu();
|
|
618 |
mainMenu->removeAction(mSubjectAction);
|
|
619 |
mSubjectAction->setParent(NULL);
|
|
620 |
delete mSubjectAction;
|
|
621 |
}
|
|
622 |
}
|
|
623 |
|
|
624 |
void MsgUnifiedEditorView::addCcBcc()
|
|
625 |
{
|
|
626 |
if(mCcField && mBccField)
|
|
627 |
{ // do nothing if already present
|
|
628 |
return;
|
|
629 |
}
|
|
630 |
|
|
631 |
mCcField = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget );
|
|
632 |
mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget );
|
|
633 |
mCcField->skipMaxRecipientQuery(true);
|
|
634 |
mBccField->skipMaxRecipientQuery(true);
|
|
635 |
|
|
636 |
connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send()));
|
|
637 |
connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
|
|
638 |
connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
|
|
639 |
|
|
640 |
connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send()));
|
|
641 |
connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
|
|
642 |
connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
|
|
643 |
|
|
644 |
HbWidget* groupWidget = new HbWidget(mContentWidget);
|
|
645 |
groupWidget->setContentsMargins(0,0,0,0);
|
|
646 |
|
|
647 |
QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget);
|
|
648 |
ccBccLayout->setContentsMargins(0,0,0,0);
|
|
649 |
|
|
650 |
qreal vItemSpacing = 0.0;
|
|
651 |
style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
|
|
652 |
ccBccLayout->setSpacing(vItemSpacing);
|
|
653 |
ccBccLayout->addItem(mCcField);
|
|
654 |
ccBccLayout->addItem(mBccField);
|
|
655 |
|
|
656 |
HbGroupBox* groupBox = new HbGroupBox(0);
|
|
657 |
groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
|
|
658 |
|
|
659 |
groupBox->setContentWidget(groupWidget);
|
|
660 |
groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
|
|
661 |
mMainLayout->insertItem(1,groupBox);
|
|
662 |
connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
|
|
663 |
|
|
664 |
// add subject field too
|
|
665 |
addSubject();
|
|
666 |
|
|
667 |
//set focus to Cc field.
|
|
668 |
HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender());
|
|
669 |
if(mCcBccAction)
|
|
670 |
{
|
|
671 |
setFocus(mCcField);
|
|
672 |
}
|
|
673 |
|
|
674 |
// remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
|
|
675 |
if(mCcBccAction)
|
|
676 |
{
|
|
677 |
HbMenu* mainmenu = this->menu();
|
|
678 |
mainmenu->removeAction(mCcBccAction);
|
|
679 |
mCcBccAction->setParent(NULL);
|
|
680 |
delete mCcBccAction;
|
|
681 |
}
|
|
682 |
|
|
683 |
this->updateGeometry();
|
|
684 |
}
|
|
685 |
|
|
686 |
void MsgUnifiedEditorView::updateOtherRecipientCount(bool state)
|
|
687 |
{
|
|
688 |
HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender());
|
|
689 |
if(groupBox)
|
|
690 |
{
|
|
691 |
if(!state)
|
|
692 |
{
|
|
693 |
groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
|
|
694 |
}
|
|
695 |
else
|
|
696 |
{
|
|
697 |
int addrCount = mCcField->addressCount();
|
|
698 |
addrCount += mBccField->addressCount();
|
|
699 |
groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));
|
|
700 |
}
|
|
701 |
}
|
|
702 |
}
|
|
703 |
|
|
704 |
void MsgUnifiedEditorView::changePriority()
|
|
705 |
{
|
|
706 |
HbAction* action = qobject_cast<HbAction*>(sender());
|
|
707 |
|
|
708 |
ConvergedMessage::Priority priority = ConvergedMessage::Normal;
|
|
709 |
if(action)
|
|
710 |
{
|
|
711 |
int data = action->data().toInt();
|
|
712 |
priority = ConvergedMessage::Priority(data);
|
|
713 |
}
|
|
714 |
|
|
715 |
addSubject();
|
|
716 |
mSubjectField->setPriority(priority);
|
|
717 |
}
|
|
718 |
|
|
719 |
void MsgUnifiedEditorView::sendingOptions()
|
|
720 |
{
|
|
721 |
}
|
|
722 |
|
|
723 |
void MsgUnifiedEditorView::deleteMessage()
|
|
724 |
{
|
|
725 |
HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
|
|
726 |
LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
|
|
727 |
}
|
|
728 |
|
|
729 |
void MsgUnifiedEditorView::removeAttachmentContainer()
|
|
730 |
{
|
|
731 |
if(mAttachmentContainer)
|
|
732 |
{
|
|
733 |
mMainLayout->removeItem(mAttachmentContainer);
|
|
734 |
mAttachmentContainer->setParent(NULL);
|
|
735 |
delete mAttachmentContainer;
|
|
736 |
mAttachmentContainer = NULL;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
|
|
740 |
void MsgUnifiedEditorView::addAttachments(QStringList files)
|
|
741 |
{
|
|
742 |
int fcount = files.count();
|
|
743 |
int i=0;
|
|
744 |
for(i=0; i<fcount; i++)
|
|
745 |
{
|
|
746 |
int status = addAttachment(files.at(i));
|
|
747 |
if(status == MsgAttachmentContainer::EAddSizeExceed)
|
|
748 |
{
|
|
749 |
QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS)
|
|
750 |
.arg(fcount-i).arg(fcount);
|
|
751 |
HbNotificationDialog::launchDialog(displayStr);
|
|
752 |
break;
|
|
753 |
}
|
|
754 |
}
|
|
755 |
}
|
|
756 |
|
|
757 |
int MsgUnifiedEditorView::addAttachment(const QString& filepath)
|
|
758 |
{
|
|
759 |
if(!mAttachmentContainer)
|
|
760 |
{
|
|
761 |
mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
|
|
762 |
connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()),
|
|
763 |
this, SLOT(removeAttachmentContainer()));
|
|
764 |
connect(mAttachmentContainer, SIGNAL(contentChanged()),
|
|
765 |
mMsgMonitor, SLOT(handleContentChange()));
|
|
766 |
connect(mAttachmentContainer, SIGNAL(contentChanged()),
|
|
767 |
this,SLOT(onContentChanged()));
|
|
768 |
|
|
769 |
int index = mMainLayout->count() - 1;
|
|
770 |
mMainLayout->insertItem(index,mAttachmentContainer);
|
|
771 |
}
|
|
772 |
|
|
773 |
int ret = mAttachmentContainer->addAttachment(filepath);
|
|
774 |
if(ret != MsgAttachmentContainer::EAddSuccess)
|
|
775 |
{
|
|
776 |
// delete container, if it is empty
|
|
777 |
if(mAttachmentContainer->count() == 0)
|
|
778 |
{
|
|
779 |
removeAttachmentContainer();
|
|
780 |
}
|
|
781 |
}
|
|
782 |
return ret;
|
|
783 |
}
|
|
784 |
|
|
785 |
void MsgUnifiedEditorView::send()
|
|
786 |
{
|
|
787 |
activateInputBlocker();
|
|
788 |
|
|
789 |
// first run the address validation tests
|
|
790 |
if( !mToField->validateContacts() ||
|
|
791 |
(mCcField && !mCcField->validateContacts()) ||
|
|
792 |
(mBccField && !mBccField->validateContacts()) )
|
|
793 |
{
|
|
794 |
deactivateInputBlocker();
|
|
795 |
return;
|
|
796 |
}
|
|
797 |
|
|
798 |
// converged msg for sending
|
|
799 |
ConvergedMessage msg;
|
|
800 |
ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
|
|
801 |
msg.setMessageType(messageType);
|
|
802 |
|
|
803 |
// we need to remove duplicate addresses
|
|
804 |
bool removeDuplicates = true;
|
|
805 |
ConvergedMessageAddressList addresses =
|
|
806 |
mToField->addresses(removeDuplicates);
|
|
807 |
if(messageType == ConvergedMessage::Sms &&
|
|
808 |
addresses.isEmpty())
|
|
809 |
{
|
|
810 |
// no recipient specified for sms, do not send msg
|
|
811 |
deactivateInputBlocker();
|
|
812 |
return;
|
|
813 |
}
|
|
814 |
|
|
815 |
ConvergedMessageAddressList ccAddresses;
|
|
816 |
ConvergedMessageAddressList bccAddresses;
|
|
817 |
if(mCcField)
|
|
818 |
{
|
|
819 |
ccAddresses = mCcField->addresses(removeDuplicates);
|
|
820 |
}
|
|
821 |
if(mBccField)
|
|
822 |
{
|
|
823 |
bccAddresses = mBccField->addresses(removeDuplicates);
|
|
824 |
}
|
|
825 |
if( messageType == ConvergedMessage::Mms &&
|
|
826 |
addresses.isEmpty() &&
|
|
827 |
ccAddresses.isEmpty() &&
|
|
828 |
bccAddresses.isEmpty())
|
|
829 |
{
|
|
830 |
// no recipient specified for mms, do not send msg
|
|
831 |
deactivateInputBlocker();
|
|
832 |
return;
|
|
833 |
}
|
|
834 |
|
|
835 |
//close vkb before switching view.
|
|
836 |
mVkbHost->closeKeypad(true);
|
|
837 |
|
|
838 |
packMessage(msg);
|
|
839 |
|
|
840 |
// send message
|
|
841 |
MsgSendUtil *sendUtil = new MsgSendUtil(this);
|
|
842 |
int sendResult = sendUtil->send(msg);
|
|
843 |
delete sendUtil;
|
|
844 |
|
|
845 |
// all checks and validations happen before send
|
|
846 |
if( sendResult == KErrNone)
|
|
847 |
{
|
|
848 |
//After sending the new content to drafts chk if the msg
|
|
849 |
//was originally opened from drafts and delete the opened entry
|
|
850 |
if( mOpenedMessageId.getId() != -1)
|
|
851 |
{
|
|
852 |
|
|
853 |
if(!mPluginLoader)
|
|
854 |
{
|
|
855 |
mPluginLoader = new UniEditorPluginLoader(this);
|
|
856 |
}
|
|
857 |
|
|
858 |
UniEditorPluginInterface* pluginInterface =
|
|
859 |
mPluginLoader->getUniEditorPlugin(messageType);
|
|
860 |
//TODO delete the entry
|
|
861 |
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
|
|
862 |
}
|
|
863 |
|
|
864 |
ConvergedMessageAddressList addrList = addresses;
|
|
865 |
QString receipient;
|
|
866 |
|
|
867 |
int recepientCount = addrList.count();
|
|
868 |
if(recepientCount)
|
|
869 |
{
|
|
870 |
receipient = addrList.at(0)->address();
|
|
871 |
}
|
|
872 |
|
|
873 |
if( mCcField && mBccField)
|
|
874 |
{
|
|
875 |
addrList = ccAddresses;
|
|
876 |
int ccCount = addrList.count();
|
|
877 |
recepientCount += ccCount;
|
|
878 |
if(ccCount)
|
|
879 |
{
|
|
880 |
receipient = addrList.at(0)->address();
|
|
881 |
}
|
|
882 |
|
|
883 |
addrList = bccAddresses;
|
|
884 |
int bccCount = addrList.count();
|
|
885 |
recepientCount += bccCount;
|
|
886 |
if(bccCount)
|
|
887 |
{
|
|
888 |
receipient = addrList.at(0)->address();
|
|
889 |
}
|
|
890 |
}
|
|
891 |
|
|
892 |
QVariantList params;
|
|
893 |
|
|
894 |
if(recepientCount == 1 )
|
|
895 |
{
|
|
896 |
params << MsgBaseView::CV; // target view
|
|
897 |
params << MsgBaseView::UNIEDITOR; // source view
|
|
898 |
|
|
899 |
params << receipient;
|
|
900 |
}
|
|
901 |
else
|
|
902 |
{
|
|
903 |
params << MsgBaseView::CLV;// target view
|
|
904 |
params << MsgBaseView::UNIEDITOR; // source view
|
|
905 |
}
|
|
906 |
deactivateInputBlocker();
|
|
907 |
emit switchView(params);
|
|
908 |
}
|
|
909 |
else
|
|
910 |
{
|
|
911 |
deactivateInputBlocker();
|
|
912 |
if(sendResult == KErrNotFound)
|
|
913 |
{
|
|
914 |
if (messageType == ConvergedMessage::Sms)
|
|
915 |
{
|
|
916 |
HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
|
|
917 |
this,SLOT(onDialogSmsSettings(HbAction*)),
|
|
918 |
LOC_DIALOG_OK,
|
|
919 |
LOC_BUTTON_CANCEL);
|
|
920 |
}
|
|
921 |
else
|
|
922 |
{
|
|
923 |
HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
|
|
924 |
this,SLOT(onDialogMmsSettings(HbAction*)),
|
|
925 |
LOC_DIALOG_OK,
|
|
926 |
LOC_BUTTON_CANCEL);
|
|
927 |
}
|
|
928 |
}
|
|
929 |
}
|
|
930 |
}
|
|
931 |
|
|
932 |
void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
|
|
933 |
{
|
|
934 |
ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
|
|
935 |
msg.setMessageType(messageType);
|
|
936 |
// If isSave is true (save to draft usecase), then don't remove duplicates
|
|
937 |
// If isSave is false (send usecase), then remove duplicates
|
|
938 |
bool removeDuplicates = !isSave;
|
|
939 |
ConvergedMessageAddressList addresses =
|
|
940 |
mToField->addresses(removeDuplicates);
|
|
941 |
ConvergedMessageAddressList ccAddresses;
|
|
942 |
ConvergedMessageAddressList bccAddresses;
|
|
943 |
|
|
944 |
msg.addToRecipients(addresses);
|
|
945 |
msg.setBodyText(mBody->text());
|
|
946 |
msg.setDirection(ConvergedMessage::Outgoing);
|
|
947 |
QDateTime time = QDateTime::currentDateTime();
|
|
948 |
msg.setTimeStamp(time.toTime_t());
|
|
949 |
|
|
950 |
if(messageType == ConvergedMessage::Mms)
|
|
951 |
{
|
|
952 |
if(mCcField)
|
|
953 |
{
|
|
954 |
ccAddresses = mCcField->addresses(removeDuplicates);
|
|
955 |
}
|
|
956 |
|
|
957 |
if(mBccField)
|
|
958 |
{
|
|
959 |
bccAddresses = mBccField->addresses(removeDuplicates);
|
|
960 |
}
|
|
961 |
|
|
962 |
if(removeDuplicates)
|
|
963 |
{
|
|
964 |
int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits();
|
|
965 |
//comapre cc and to field,remove duplicate from cc
|
|
966 |
foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
|
|
967 |
{
|
|
968 |
foreach(ConvergedMessageAddress *toAddress,addresses)
|
|
969 |
{
|
|
970 |
if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
|
|
971 |
{
|
|
972 |
ccAddresses.removeOne(ccAddress);
|
|
973 |
}
|
|
974 |
}
|
|
975 |
}
|
|
976 |
//comapre bcc and cc field,remove duplicate from bcc
|
|
977 |
foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
|
|
978 |
{
|
|
979 |
foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
|
|
980 |
{
|
|
981 |
if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount)))
|
|
982 |
{
|
|
983 |
bccAddresses.removeOne(bccAddress);
|
|
984 |
}
|
|
985 |
}
|
|
986 |
}
|
|
987 |
//comapre bcc and to field,remove duplicate from bcc
|
|
988 |
foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
|
|
989 |
{
|
|
990 |
foreach(ConvergedMessageAddress *toAddress,addresses)
|
|
991 |
{
|
|
992 |
if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
|
|
993 |
{
|
|
994 |
bccAddresses.removeOne(bccAddress);
|
|
995 |
}
|
|
996 |
}
|
|
997 |
}
|
|
998 |
}
|
|
999 |
|
|
1000 |
if(ccAddresses.count()>0)
|
|
1001 |
{
|
|
1002 |
msg.addCcRecipients(ccAddresses);
|
|
1003 |
}
|
|
1004 |
if(bccAddresses.count()>0)
|
|
1005 |
{
|
|
1006 |
msg.addBccRecipients(bccAddresses);
|
|
1007 |
}
|
|
1008 |
if(mSubjectField)
|
|
1009 |
{
|
|
1010 |
msg.setSubject(mSubjectField->text());
|
|
1011 |
msg.setPriority(mSubjectField->priority());
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
ConvergedMessageAttachmentList mediaList;
|
|
1015 |
|
|
1016 |
QStringList mediafiles(mBody->mediaContent());
|
|
1017 |
if (!mediafiles.isEmpty())
|
|
1018 |
{
|
|
1019 |
for (int i = 0; i < mediafiles.size(); ++i)
|
|
1020 |
{
|
|
1021 |
ConvergedMessageAttachment* attachment =
|
|
1022 |
new ConvergedMessageAttachment(
|
|
1023 |
mediafiles.at(i),
|
|
1024 |
ConvergedMessageAttachment::EInline);
|
|
1025 |
mediaList << attachment;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
}
|
|
1029 |
if(mediaList.count() > 0)
|
|
1030 |
{
|
|
1031 |
msg.addAttachments(mediaList);
|
|
1032 |
}
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
// sms/mms attachment list
|
|
1036 |
ConvergedMessageAttachmentList attachmentList;
|
|
1037 |
if(mAttachmentContainer)
|
|
1038 |
{
|
|
1039 |
MsgUnifiedEditorAttachmentList editorAttachmentList =
|
|
1040 |
mAttachmentContainer->attachmentList();
|
|
1041 |
for (int i = 0; i < editorAttachmentList.count(); ++i)
|
|
1042 |
{
|
|
1043 |
ConvergedMessageAttachment* attachment =
|
|
1044 |
new ConvergedMessageAttachment(
|
|
1045 |
editorAttachmentList.at(i)->path(),
|
|
1046 |
ConvergedMessageAttachment::EAttachment);
|
|
1047 |
attachmentList << attachment;
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
if(attachmentList.count() > 0)
|
|
1051 |
{
|
|
1052 |
msg.addAttachments(attachmentList);
|
|
1053 |
}
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
void MsgUnifiedEditorView::saveContentToDrafts()
|
|
1057 |
{
|
|
1058 |
if(!mCanSaveToDrafts)
|
|
1059 |
{
|
|
1060 |
return;
|
|
1061 |
}
|
|
1062 |
activateInputBlocker();
|
|
1063 |
ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
|
|
1064 |
|
|
1065 |
ConvergedMessageAddressList addresses = mToField->addresses();
|
|
1066 |
|
|
1067 |
UniEditorPluginInterface* pluginInterface = NULL;
|
|
1068 |
|
|
1069 |
if( mOpenedMessageId.getId() != -1)
|
|
1070 |
{
|
|
1071 |
if(!mPluginLoader)
|
|
1072 |
{
|
|
1073 |
mPluginLoader = new UniEditorPluginLoader(this);
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
pluginInterface =
|
|
1077 |
mPluginLoader->getUniEditorPlugin(messageType);
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
if(messageType == ConvergedMessage::Sms &&
|
|
1081 |
addresses.isEmpty() &&
|
|
1082 |
MsgMonitor::bodySize() <= 0 &&
|
|
1083 |
MsgMonitor::containerSize() <= 0)
|
|
1084 |
{
|
|
1085 |
if(mOpenedMessageId.getId() != -1)
|
|
1086 |
{
|
|
1087 |
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
|
|
1088 |
}
|
|
1089 |
|
|
1090 |
// if empty msg, do not save
|
|
1091 |
deactivateInputBlocker();
|
|
1092 |
return;
|
|
1093 |
}
|
|
1094 |
|
|
1095 |
ConvergedMessageAddressList ccAddresses;
|
|
1096 |
ConvergedMessageAddressList bccAddresses;
|
|
1097 |
if(mCcField)
|
|
1098 |
{
|
|
1099 |
ccAddresses = mCcField->addresses();
|
|
1100 |
}
|
|
1101 |
if(mBccField)
|
|
1102 |
{
|
|
1103 |
bccAddresses = mBccField->addresses();
|
|
1104 |
}
|
|
1105 |
int subectSize =0;
|
|
1106 |
if(mSubjectField)
|
|
1107 |
{
|
|
1108 |
subectSize = mSubjectField->text().size();
|
|
1109 |
}
|
|
1110 |
|
|
1111 |
if( messageType == ConvergedMessage::Mms &&
|
|
1112 |
addresses.isEmpty() &&
|
|
1113 |
ccAddresses.isEmpty() &&
|
|
1114 |
bccAddresses.isEmpty() &&
|
|
1115 |
subectSize <= 0 &&
|
|
1116 |
MsgMonitor::bodySize() <= 0 &&
|
|
1117 |
MsgMonitor::containerSize() <= 0)
|
|
1118 |
{
|
|
1119 |
if(mOpenedMessageId.getId() != -1)
|
|
1120 |
{
|
|
1121 |
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
|
|
1122 |
}
|
|
1123 |
// if empty msg, do not send
|
|
1124 |
deactivateInputBlocker();
|
|
1125 |
return;
|
|
1126 |
}
|
|
1127 |
ConvergedMessage msg;
|
|
1128 |
packMessage(msg, true);
|
|
1129 |
|
|
1130 |
// save to drafts
|
|
1131 |
MsgSendUtil *sendUtil = new MsgSendUtil(this);
|
|
1132 |
int msgId = sendUtil->saveToDrafts(msg);
|
|
1133 |
delete sendUtil;
|
|
1134 |
|
|
1135 |
// If saving new msg to draft succeeded and also if the originally
|
|
1136 |
// opened msg was from drafts, then delete the original msg entry
|
|
1137 |
if(msgId != -1 && mOpenedMessageId.getId() != -1)
|
|
1138 |
{
|
|
1139 |
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
|
|
1140 |
mOpenedMessageId.setId(INVALID_MSGID);
|
|
1141 |
}
|
|
1142 |
|
|
1143 |
deactivateInputBlocker();
|
|
1144 |
|
|
1145 |
bool res = ((msgId > INVALID_MSGID)? true : false);
|
|
1146 |
|
|
1147 |
if(res)
|
|
1148 |
{
|
|
1149 |
HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
|
|
1150 |
}
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
|
|
1154 |
{
|
|
1155 |
Q_UNUSED(event)
|
|
1156 |
#ifdef _DEBUG_TRACES_
|
|
1157 |
qDebug()<<"resize event";
|
|
1158 |
#endif
|
|
1159 |
|
|
1160 |
mContentWidget->resize(this->rect().width(),this->rect().height()+1);
|
|
1161 |
}
|
|
1162 |
|
|
1163 |
//---------------------------------------------------------------
|
|
1164 |
// MsgUnifiedEditorView::createVCards
|
|
1165 |
// @see header file
|
|
1166 |
//---------------------------------------------------------------
|
|
1167 |
int MsgUnifiedEditorView::createVCards(
|
|
1168 |
const QVariant& value, QStringList& filelist)
|
|
1169 |
{
|
|
1170 |
// make sure that temp-folder is created for storing vcards
|
|
1171 |
if(!createTempFolder())
|
|
1172 |
{
|
|
1173 |
return KErrGeneral;
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
// extract contact-list
|
|
1177 |
QContactManager* contactManager = new QContactManager("symbian");
|
|
1178 |
CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value);
|
|
1179 |
int cntCount = cntServicesContacts.count();
|
|
1180 |
QList<QtMobility::QContact> contactList;
|
|
1181 |
for(int i = 0; i < cntCount; i++ )
|
|
1182 |
{
|
|
1183 |
contactList << contactManager->contact( cntServicesContacts.at(i).mContactId );
|
|
1184 |
}
|
|
1185 |
delete contactManager;
|
|
1186 |
|
|
1187 |
// get list of all versit-documents
|
|
1188 |
QVersitDocument::VersitType versitType(QVersitDocument::VCard21Type);
|
|
1189 |
QVersitContactExporter* exporter = new QVersitContactExporter();
|
|
1190 |
|
|
1191 |
bool ret_val = exporter->exportContacts(contactList, versitType);
|
|
1192 |
QList<QtMobility::QVersitDocument> documentList = exporter->documents();
|
|
1193 |
|
|
1194 |
delete exporter;
|
|
1195 |
|
|
1196 |
// loop though and create a vcard for each contact
|
|
1197 |
QVersitWriter* writer = new QVersitWriter();
|
|
1198 |
for(int i = 0; i < cntCount; i++ )
|
|
1199 |
{
|
|
1200 |
// buffer to hold vcard data fetched from contacts
|
|
1201 |
QBuffer contactsbuf;
|
|
1202 |
contactsbuf.open(QBuffer::ReadWrite);
|
|
1203 |
writer->setDevice( &contactsbuf );
|
|
1204 |
|
|
1205 |
//write document data to buffer
|
|
1206 |
QList<QtMobility::QVersitDocument> currDoc;
|
|
1207 |
currDoc << documentList.at(i);
|
|
1208 |
writer->startWriting(currDoc);
|
|
1209 |
if(writer->waitForFinished())
|
|
1210 |
{
|
|
1211 |
// generate file name
|
|
1212 |
QString displayLabel = contactList.at(i).displayLabel();
|
|
1213 |
QString filepath = generateFileName(displayLabel);
|
|
1214 |
QFile file(filepath);
|
|
1215 |
if(file.open(QIODevice::WriteOnly))
|
|
1216 |
{
|
|
1217 |
// trap ignore so that, incase of multiselection, other vcards are still created
|
|
1218 |
QByteArray bufArr;
|
|
1219 |
TRAP_IGNORE(
|
|
1220 |
CBufBase* contactbufbase = CBufFlat::NewL(contactsbuf.size());
|
|
1221 |
CleanupStack::PushL(contactbufbase);
|
|
1222 |
contactbufbase->InsertL( contactbufbase->Size(),
|
|
1223 |
*XQConversions::qStringToS60Desc8( contactsbuf.data() ) );
|
|
1224 |
TPtr8 ptrbuf(contactbufbase->Ptr(0));
|
|
1225 |
bufArr = XQConversions::s60Desc8ToQByteArray(ptrbuf);
|
|
1226 |
CleanupStack::PopAndDestroy(contactbufbase);
|
|
1227 |
);
|
|
1228 |
file.write(bufArr);
|
|
1229 |
file.close();
|
|
1230 |
filelist << filepath;
|
|
1231 |
}
|
|
1232 |
}
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
// cleanup & return
|
|
1236 |
delete writer;
|
|
1237 |
return KErrNone;
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
|
|
1241 |
//---------------------------------------------------------------
|
|
1242 |
// MsgUnifiedEditorView::generateFileName
|
|
1243 |
// @param suggestedName suggested name of the file
|
|
1244 |
// @return fullPath of the generated filename
|
|
1245 |
// @algo For multiselected 'Unnamed' contacts, the filename should
|
|
1246 |
// be synthesized as unnamed.vcf, unnamed1.vcf, unnamed2.vcf etc.
|
|
1247 |
//---------------------------------------------------------------
|
|
1248 |
QString MsgUnifiedEditorView::generateFileName(QString& suggestedName)
|
|
1249 |
{
|
|
1250 |
QDir editorTempDir;
|
|
1251 |
editorTempDir.cd(editorTempPath());
|
|
1252 |
|
|
1253 |
for(int i=0; i<MAX_VCARDS; i++)
|
|
1254 |
{
|
|
1255 |
QString searchFileName = suggestedName;
|
|
1256 |
if(i>0)
|
|
1257 |
{
|
|
1258 |
searchFileName.append(QString::number(i));
|
|
1259 |
}
|
|
1260 |
searchFileName.append(FILE_EXTN);
|
|
1261 |
|
|
1262 |
// check if filename is already used by an attachment in container
|
|
1263 |
bool alreadyExists = false;
|
|
1264 |
if(mAttachmentContainer)
|
|
1265 |
{
|
|
1266 |
MsgUnifiedEditorAttachmentList attList =
|
|
1267 |
mAttachmentContainer->attachmentList();
|
|
1268 |
int attCount = attList.count();
|
|
1269 |
for(int j=0; j<attCount; j++)
|
|
1270 |
{
|
|
1271 |
QFileInfo fileinfo(attList.at(j)->path());
|
|
1272 |
if(searchFileName == fileinfo.fileName())
|
|
1273 |
{
|
|
1274 |
alreadyExists = true;
|
|
1275 |
break;
|
|
1276 |
}
|
|
1277 |
}
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
if(!alreadyExists)
|
|
1281 |
{
|
|
1282 |
if(i>0)
|
|
1283 |
{
|
|
1284 |
suggestedName.append(QString::number(i));
|
|
1285 |
}
|
|
1286 |
break;
|
|
1287 |
}
|
|
1288 |
}
|
|
1289 |
QString filepath(editorTempPath());
|
|
1290 |
filepath.append(suggestedName);
|
|
1291 |
filepath.append(FILE_EXTN);
|
|
1292 |
return filepath;
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
void MsgUnifiedEditorView::handleViewExtnActivated(HbListWidgetItem* item)
|
|
1296 |
{
|
|
1297 |
QString itemText = item->text();
|
|
1298 |
|
|
1299 |
if(itemText == LOC_PHOTO)
|
|
1300 |
{
|
|
1301 |
//launch photo picker.
|
|
1302 |
fetchImages();
|
|
1303 |
}
|
|
1304 |
else if(itemText == LOC_SOUND)
|
|
1305 |
{
|
|
1306 |
//launch audio picker
|
|
1307 |
fetchAudio();
|
|
1308 |
}
|
|
1309 |
else if(itemText == LOC_BUSINESS_CARD)
|
|
1310 |
{
|
|
1311 |
//launch contact card picker.
|
|
1312 |
fetchContacts();
|
|
1313 |
}
|
|
1314 |
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
//---------------------------------------------------------------
|
|
1318 |
// MsgUnifiedEditorView::fetchContacts
|
|
1319 |
// @see header file
|
|
1320 |
//---------------------------------------------------------------
|
|
1321 |
void MsgUnifiedEditorView::fetchContacts()
|
|
1322 |
{
|
|
1323 |
QList<QVariant> args;
|
|
1324 |
QString serviceName("com.nokia.services.phonebookservices");
|
|
1325 |
QString operation("fetch(QString,QString,QString)");
|
|
1326 |
XQAiwRequest* request;
|
|
1327 |
XQApplicationManager appManager;
|
|
1328 |
request = appManager.create(serviceName, "Fetch", operation, true); //embedded
|
|
1329 |
if ( request == NULL )
|
|
1330 |
{
|
|
1331 |
QCRITICAL_WRITE("AIW-ERROR: NULL request");
|
|
1332 |
return;
|
|
1333 |
}
|
|
1334 |
|
|
1335 |
// Result handlers
|
|
1336 |
connect (request, SIGNAL(requestOk(const QVariant&)),
|
|
1337 |
this, SLOT(contactsFetched(const QVariant&)));
|
|
1338 |
connect (request, SIGNAL(requestError(int,const QString&)),
|
|
1339 |
this, SLOT(serviceRequestError(int,const QString&)));
|
|
1340 |
|
|
1341 |
args << QString(tr("Phonebook"));
|
|
1342 |
args << KCntActionAll;
|
|
1343 |
args << KCntFilterDisplayAll;
|
|
1344 |
|
|
1345 |
request->setArguments(args);
|
|
1346 |
if(!request->send())
|
|
1347 |
{
|
|
1348 |
QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:",request->lastError());
|
|
1349 |
}
|
|
1350 |
delete request;
|
|
1351 |
}
|
|
1352 |
|
|
1353 |
//---------------------------------------------------------------
|
|
1354 |
// MsgUnifiedEditorView::fetchImages
|
|
1355 |
// @see header file
|
|
1356 |
//---------------------------------------------------------------
|
|
1357 |
void MsgUnifiedEditorView::fetchImages()
|
|
1358 |
{
|
|
1359 |
QString interface("Image");
|
|
1360 |
QString operation("fetch(QVariantMap,QVariant)");
|
|
1361 |
XQAiwRequest* request = NULL;
|
|
1362 |
XQApplicationManager appManager;
|
|
1363 |
request = appManager.create(interface, operation, true);//embedded
|
|
1364 |
request->setSynchronous(true); // synchronous
|
|
1365 |
if(!request)
|
|
1366 |
{
|
|
1367 |
QCRITICAL_WRITE("AIW-ERROR: NULL request");
|
|
1368 |
return;
|
|
1369 |
}
|
|
1370 |
|
|
1371 |
connect(request, SIGNAL(requestOk(const QVariant&)),
|
|
1372 |
this, SLOT(imagesFetched(const QVariant&)));
|
|
1373 |
connect(request, SIGNAL(requestError(int,const QString&)),
|
|
1374 |
this, SLOT(serviceRequestError(int,const QString&)));
|
|
1375 |
|
|
1376 |
// Set arguments for request
|
|
1377 |
QList<QVariant> args;
|
|
1378 |
args << QVariantMap();
|
|
1379 |
args << QVariant();
|
|
1380 |
request->setArguments(args);
|
|
1381 |
// Make the request
|
|
1382 |
if (!request->send())
|
|
1383 |
{
|
|
1384 |
QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
|
|
1385 |
}
|
|
1386 |
delete request;
|
|
1387 |
}
|
|
1388 |
|
|
1389 |
//---------------------------------------------------------------
|
|
1390 |
// MsgUnifiedEditorView::fetchAudio
|
|
1391 |
// @see header file
|
|
1392 |
//---------------------------------------------------------------
|
|
1393 |
void MsgUnifiedEditorView::fetchAudio()
|
|
1394 |
{
|
|
1395 |
QString service("musicplayer");
|
|
1396 |
QString interface("com.nokia.symbian.IMusicFetch");
|
|
1397 |
QString operation("fetch()");
|
|
1398 |
XQAiwRequest* request = NULL;
|
|
1399 |
XQApplicationManager appManager;
|
|
1400 |
request = appManager.create(service, interface, operation, true); //embedded
|
|
1401 |
request->setSynchronous(true); // synchronous
|
|
1402 |
if(!request)
|
|
1403 |
{
|
|
1404 |
QCRITICAL_WRITE("AIW-ERROR: NULL request");
|
|
1405 |
return;
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
connect(request, SIGNAL(requestOk(const QVariant&)),
|
|
1409 |
this, SLOT(audiosFetched(const QVariant&)));
|
|
1410 |
connect(request, SIGNAL(requestError(int,const QString&)),
|
|
1411 |
this, SLOT(serviceRequestError(int,const QString&)));
|
|
1412 |
|
|
1413 |
// Make the request
|
|
1414 |
if (!request->send())
|
|
1415 |
{
|
|
1416 |
QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed :",request->lastError());
|
|
1417 |
}
|
|
1418 |
delete request;
|
|
1419 |
}
|
|
1420 |
|
|
1421 |
//---------------------------------------------------------------
|
|
1422 |
// MsgUnifiedEditorView::contactsFetched
|
|
1423 |
// @see header file
|
|
1424 |
//---------------------------------------------------------------
|
|
1425 |
void MsgUnifiedEditorView::contactsFetched(const QVariant& value)
|
|
1426 |
{
|
|
1427 |
// create a vcard for each contact fetched and add as attachment
|
|
1428 |
QStringList attachmentList;
|
|
1429 |
if(createVCards(value, attachmentList) == KErrNone)
|
|
1430 |
{
|
|
1431 |
addAttachments(attachmentList);
|
|
1432 |
}
|
|
1433 |
}
|
|
1434 |
|
|
1435 |
//---------------------------------------------------------------
|
|
1436 |
// MsgUnifiedEditorView::imagesFetched
|
|
1437 |
// @see header file
|
|
1438 |
//---------------------------------------------------------------
|
|
1439 |
void MsgUnifiedEditorView::imagesFetched(const QVariant& result )
|
|
1440 |
{
|
|
1441 |
if(result.canConvert<QStringList>())
|
|
1442 |
{
|
|
1443 |
QStringList fileList = result.value<QStringList>();
|
|
1444 |
if ( fileList.size()>0 )
|
|
1445 |
{
|
|
1446 |
QString filepath(QDir::toNativeSeparators(fileList.at(0)));
|
|
1447 |
mBody->setImage(filepath);
|
|
1448 |
}
|
|
1449 |
}
|
|
1450 |
}
|
|
1451 |
|
|
1452 |
//---------------------------------------------------------------
|
|
1453 |
// MsgUnifiedEditorView::audiosFetched
|
|
1454 |
// @see header file
|
|
1455 |
//---------------------------------------------------------------
|
|
1456 |
void MsgUnifiedEditorView::audiosFetched(const QVariant& result )
|
|
1457 |
{
|
|
1458 |
if(result.canConvert<QStringList>())
|
|
1459 |
{
|
|
1460 |
QStringList fileList = result.value<QStringList>();
|
|
1461 |
if ( fileList.size()>0 && !fileList.at(0).isEmpty())
|
|
1462 |
{
|
|
1463 |
QString filepath(QDir::toNativeSeparators(fileList.at(0)));
|
|
1464 |
QDEBUG_WRITE_FORMAT("Received audio file path = ", fileList.at(0));
|
|
1465 |
mBody->setAudio(filepath);
|
|
1466 |
}
|
|
1467 |
}
|
|
1468 |
}
|
|
1469 |
|
|
1470 |
//---------------------------------------------------------------
|
|
1471 |
// MsgUnifiedEditorView::serviceRequestError
|
|
1472 |
// @see header file
|
|
1473 |
//---------------------------------------------------------------
|
|
1474 |
void MsgUnifiedEditorView::serviceRequestError(int errorCode, const QString& errorMessage)
|
|
1475 |
{
|
|
1476 |
QDEBUG_WRITE_FORMAT(errorMessage,errorCode);
|
|
1477 |
}
|
|
1478 |
|
|
1479 |
//---------------------------------------------------------------
|
|
1480 |
// MsgUnifiedEditorView::activateInputBlocker
|
|
1481 |
// @see header file
|
|
1482 |
//--------------------------------------------------------------
|
|
1483 |
void MsgUnifiedEditorView::activateInputBlocker()
|
|
1484 |
{
|
|
1485 |
this->grabMouse();
|
|
1486 |
this->grabKeyboard();
|
|
1487 |
}
|
|
1488 |
|
|
1489 |
//---------------------------------------------------------------
|
|
1490 |
// MsgUnifiedEditorView::deactivateInputBlocker
|
|
1491 |
// @see header file
|
|
1492 |
//--------------------------------------------------------------
|
|
1493 |
void MsgUnifiedEditorView::deactivateInputBlocker()
|
|
1494 |
{
|
|
1495 |
this->ungrabKeyboard();
|
|
1496 |
this->ungrabMouse();
|
|
1497 |
}
|
|
1498 |
|
|
1499 |
//---------------------------------------------------------------
|
|
1500 |
// MsgUnifiedEditorView::setAttachOptionEnabled
|
|
1501 |
// @see header file
|
|
1502 |
//--------------------------------------------------------------
|
|
1503 |
void MsgUnifiedEditorView::setAttachOptionEnabled(
|
|
1504 |
MsgUnifiedEditorView::TBE_AttachOption opt, bool enable)
|
|
1505 |
{
|
|
1506 |
HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt);
|
|
1507 |
wgtItem->setEnabled(enable);
|
|
1508 |
}
|
|
1509 |
|
|
1510 |
//---------------------------------------------------------------
|
|
1511 |
// MsgUnifiedEditorView::vkbOpened
|
|
1512 |
// @see header file
|
|
1513 |
//---------------------------------------------------------------
|
|
1514 |
void MsgUnifiedEditorView::vkbOpened()
|
|
1515 |
{
|
|
1516 |
hideChrome(true);
|
|
1517 |
|
|
1518 |
disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
|
|
1519 |
}
|
|
1520 |
|
|
1521 |
//---------------------------------------------------------------
|
|
1522 |
// MsgUnifiedEditorView::vkbClosed
|
|
1523 |
// @see header file
|
|
1524 |
//---------------------------------------------------------------
|
|
1525 |
void MsgUnifiedEditorView::vkbClosed()
|
|
1526 |
{
|
|
1527 |
hideChrome(false);
|
|
1528 |
|
|
1529 |
connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
|
|
1530 |
}
|
|
1531 |
|
|
1532 |
//---------------------------------------------------------------
|
|
1533 |
// MsgUnifiedEditorView::hideChrome
|
|
1534 |
//
|
|
1535 |
//---------------------------------------------------------------
|
|
1536 |
void MsgUnifiedEditorView::hideChrome(bool hide)
|
|
1537 |
{
|
|
1538 |
if(hide)
|
|
1539 |
{
|
|
1540 |
this->setContentFullScreen(true);
|
|
1541 |
this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem);
|
|
1542 |
}
|
|
1543 |
else
|
|
1544 |
{
|
|
1545 |
this->setContentFullScreen(false);
|
|
1546 |
this->showItems(Hb::StatusBarItem | Hb::TitleBarItem);
|
|
1547 |
}
|
|
1548 |
}
|
|
1549 |
|
|
1550 |
//---------------------------------------------------------------
|
|
1551 |
// MsgUnifiedEditorView::doDelayedConstruction
|
|
1552 |
//
|
|
1553 |
//---------------------------------------------------------------
|
|
1554 |
void MsgUnifiedEditorView::doDelayedConstruction()
|
|
1555 |
{
|
|
1556 |
addMenu();
|
|
1557 |
createTempFolder();
|
|
1558 |
|
|
1559 |
//Create VKB instance and listen to VKB open and close signals.
|
|
1560 |
mVkbHost = new HbAbstractVkbHost(this);
|
|
1561 |
connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
|
|
1562 |
connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
|
|
1563 |
|
|
1564 |
disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
|
|
1565 |
|
|
1566 |
}
|
|
1567 |
|
|
1568 |
//---------------------------------------------------------------
|
|
1569 |
// MsgUnifiedEditorView::createTempFolder
|
|
1570 |
//
|
|
1571 |
//---------------------------------------------------------------
|
|
1572 |
bool MsgUnifiedEditorView::createTempFolder()
|
|
1573 |
{
|
|
1574 |
// create editor's temp folder
|
|
1575 |
QDir tempDir;
|
|
1576 |
QString tempPath(editorTempPath());
|
|
1577 |
bool result = tempDir.mkpath(tempPath);
|
|
1578 |
return result;
|
|
1579 |
}
|
|
1580 |
|
|
1581 |
//---------------------------------------------------------------
|
|
1582 |
// MsgUnifiedEditorView::removeTempFolder
|
|
1583 |
//
|
|
1584 |
//---------------------------------------------------------------
|
|
1585 |
void MsgUnifiedEditorView::removeTempFolder()
|
|
1586 |
{
|
|
1587 |
QDir tempDir;
|
|
1588 |
QString tempPath(editorTempPath());
|
|
1589 |
tempDir.cd(tempPath);
|
|
1590 |
QStringList contentList(tempDir.entryList());
|
|
1591 |
|
|
1592 |
int contentCount = contentList.count();
|
|
1593 |
for(int i=0; i<contentCount; i++)
|
|
1594 |
{
|
|
1595 |
tempDir.remove(contentList.at(i));
|
|
1596 |
}
|
|
1597 |
|
|
1598 |
tempDir.cdUp();
|
|
1599 |
tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER);
|
|
1600 |
}
|
|
1601 |
|
|
1602 |
//---------------------------------------------------------------
|
|
1603 |
// MsgUnifiedEditorView::setFocus
|
|
1604 |
//
|
|
1605 |
//---------------------------------------------------------------
|
|
1606 |
void MsgUnifiedEditorView::setFocus(MsgUnifiedEditorBaseWidget* item)
|
|
1607 |
{
|
|
1608 |
if(item)
|
|
1609 |
{
|
|
1610 |
item->setFocus();
|
|
1611 |
}
|
|
1612 |
}
|
|
1613 |
|
|
1614 |
//---------------------------------------------------------------
|
|
1615 |
// MsgUnifiedEditorView::onContentChanged
|
|
1616 |
//
|
|
1617 |
//---------------------------------------------------------------
|
|
1618 |
void MsgUnifiedEditorView::onContentChanged()
|
|
1619 |
{
|
|
1620 |
mCanSaveToDrafts = true;
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
//---------------------------------------------------------------
|
|
1624 |
// MsgUnifiedEditorView::onDialogDeleteMsg
|
|
1625 |
//---------------------------------------------------------------
|
|
1626 |
void MsgUnifiedEditorView::onDialogDeleteMsg(HbAction* action)
|
|
1627 |
{
|
|
1628 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
|
|
1629 |
if (action == dlg->actions().at(0)) {
|
|
1630 |
|
|
1631 |
mCanSaveToDrafts = false;
|
|
1632 |
|
|
1633 |
//delete if draft entry opened
|
|
1634 |
if (mOpenedMessageId.getId() != -1) {
|
|
1635 |
if (!mPluginLoader) {
|
|
1636 |
mPluginLoader = new UniEditorPluginLoader(this);
|
|
1637 |
}
|
|
1638 |
|
|
1639 |
UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin(
|
|
1640 |
MsgMonitor::messageType());
|
|
1641 |
|
|
1642 |
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
|
|
1643 |
}
|
|
1644 |
|
|
1645 |
//trigger back action.
|
|
1646 |
HbAction* backAction = this->navigationAction();
|
|
1647 |
if (backAction) {
|
|
1648 |
backAction->trigger();
|
|
1649 |
}
|
|
1650 |
|
|
1651 |
}
|
|
1652 |
}
|
|
1653 |
|
|
1654 |
//---------------------------------------------------------------
|
|
1655 |
// MsgUnifiedEditorView::onDialogSmsSettings
|
|
1656 |
//---------------------------------------------------------------
|
|
1657 |
void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action)
|
|
1658 |
{
|
|
1659 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
|
|
1660 |
if (action == dlg->actions().at(0)) {
|
|
1661 |
|
|
1662 |
QVariantList params;
|
|
1663 |
params << MsgBaseView::MSGSETTINGS;// target view
|
|
1664 |
params << MsgBaseView::UNIEDITOR; // source view
|
|
1665 |
params << MsgSettingsView::SMSView;
|
|
1666 |
emit switchView(params);
|
|
1667 |
|
|
1668 |
}
|
|
1669 |
}
|
|
1670 |
|
|
1671 |
//---------------------------------------------------------------
|
|
1672 |
// MsgUnifiedEditorView::onDialogMmsSettings
|
|
1673 |
//---------------------------------------------------------------
|
|
1674 |
void MsgUnifiedEditorView::onDialogMmsSettings(HbAction* action)
|
|
1675 |
{
|
|
1676 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
|
|
1677 |
if (action == dlg->actions().at(0)) {
|
|
1678 |
|
|
1679 |
QVariantList params;
|
|
1680 |
params << MsgBaseView::MSGSETTINGS;// target view
|
|
1681 |
params << MsgBaseView::UNIEDITOR; // source view
|
|
1682 |
params << MsgSettingsView::MMSView;
|
|
1683 |
emit switchView(params);
|
|
1684 |
}
|
|
1685 |
}
|
|
1686 |
|
|
1687 |
//EOF
|