--- a/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Thu Sep 02 20:23:03 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Fri Sep 17 08:28:39 2010 +0300
@@ -66,6 +66,8 @@
#include "unieditorpluginloader.h"
#include "unieditorplugininterface.h"
#include "msgsettingsview.h"
+#include "msgcontacthandler.h"
+#include "msgaudiofetcherdialog.h"
QTM_USE_NAMESPACE
// Constants
@@ -122,6 +124,8 @@
//settings confirmation
#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
#define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined")
+#define LOC_NOTE_FILES_MISSED_DRAFTS hbTrId("txt_messaging_dpopinfo_some_files_in_the_message")
+#define LOC_NOTE_FILES_MISSED_SEND hbTrId("txt_messaging_dialog_unable_to_send_message_some")
// LOCAL FUNCTIONS
//---------------------------------------------------------------
@@ -158,7 +162,11 @@
mAttachmentContainer(0),
mPluginLoader(0),
mCanSaveToDrafts(true),
- mVkbHost(NULL)
+ mVkbHost(NULL),
+ mDialog(NULL),
+ mOriginatingSC(0),
+ mOriginatingSME(0),
+ mReplyPath(false)
{
connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
@@ -174,6 +182,9 @@
{
// clean editor's temporary contents before exiting
removeTempFolder();
+
+ //delete the popup dialog
+ delete mDialog;
}
//---------------------------------------------------------------
@@ -295,6 +306,12 @@
if( msg != NULL )
{
+ mReplyPath = msg->replyPath();
+ if(mReplyPath)
+ {
+ mOriginatingSC = msg->originatingSC();
+ mOriginatingSME = msg->toAddressList().at(0)->address();
+ }
//Populate the content inside editor
populateContentIntoEditor(*msg,true); // true as it is draft message
delete msg;
@@ -330,6 +347,15 @@
(UniEditorPluginInterface::EditorOperation)editorOperation);
if( msg != NULL )
{
+ if(editorOperation == UniEditorPluginInterface::Reply)
+ {
+ mReplyPath = msg->replyPath();
+ if(mReplyPath)
+ {
+ mOriginatingSC = msg->originatingSC();
+ mOriginatingSME = msg->toAddressList().at(0)->address();
+ }
+ }
//Populate the content inside editor
populateContentIntoEditor(*msg);
delete msg;
@@ -474,14 +500,14 @@
mMsgMonitor->setSkipNote(true);
mToField->skipMaxRecipientQuery(true);
- mToField->setAddresses(messageDetails.toAddressList());
+ mToField->setAddresses(messageDetails.toAddressList(),draftMessage);
if(messageDetails.ccAddressList().count() > 0 )
{
if(!mCcField)
{
addCcBcc();
}
- mCcField->setAddresses(messageDetails.ccAddressList());
+ mCcField->setAddresses(messageDetails.ccAddressList(),draftMessage);
}
if(messageDetails.bccAddressList().count() > 0 )
{
@@ -489,7 +515,7 @@
{
addCcBcc();
}
- mBccField->setAddresses(messageDetails.bccAddressList());
+ mBccField->setAddresses(messageDetails.bccAddressList(),draftMessage);
}
if(messageDetails.subject().size() > 0)
{
@@ -860,8 +886,13 @@
//close vkb before switching view.
mVkbHost->closeKeypad(true);
- packMessage(msg);
-
+ int result = packMessage(msg);
+ if(result == KErrNotFound)
+ {
+ HbMessageBox::information(LOC_NOTE_FILES_MISSED_SEND, 0, 0, HbMessageBox::Ok);
+ deactivateInputBlocker();
+ return;
+ }
// send message
MsgSendUtil *sendUtil = new MsgSendUtil(this);
int sendResult = sendUtil->send(msg);
@@ -952,8 +983,20 @@
}
}
-void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
+int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
{
+ // reset reply-path if originating SME constraint is broken
+ if(mReplyPath && isReplyPathBroken())
+ {
+ mReplyPath = false;
+ }
+
+ msg.setReplyPath(mReplyPath);
+ if(mReplyPath)
+ {
+ msg.setOriginatingSC(mOriginatingSC);
+ }
+
ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
msg.setMessageType(messageType);
// If isSave is true (save to draft usecase), then don't remove duplicates
@@ -963,7 +1006,8 @@
mToField->addresses(removeDuplicates);
ConvergedMessageAddressList ccAddresses;
ConvergedMessageAddressList bccAddresses;
-
+ ConvergedMessageAttachmentList mediaList;
+ int errorCode = 0;
//Don't format the addresses for save to drfats case
if(!isSave)
{
@@ -1050,18 +1094,23 @@
msg.setPriority(mSubjectField->priority());
}
- ConvergedMessageAttachmentList mediaList;
-
QStringList mediafiles(mBody->mediaContent());
if (!mediafiles.isEmpty())
{
for (int i = 0; i < mediafiles.size(); ++i)
{
+ if(QFile::exists(mediafiles.at(i)))
+ {
ConvergedMessageAttachment* attachment =
new ConvergedMessageAttachment(
mediafiles.at(i),
ConvergedMessageAttachment::EInline);
mediaList << attachment;
+ }
+ else
+ { mBody->removeMediaContent(mediafiles.at(i));
+ errorCode = KErrNotFound;
+ }
}
}
@@ -1079,17 +1128,26 @@
mAttachmentContainer->attachmentList();
for (int i = 0; i < editorAttachmentList.count(); ++i)
{
- ConvergedMessageAttachment* attachment =
- new ConvergedMessageAttachment(
- editorAttachmentList.at(i)->path(),
- ConvergedMessageAttachment::EAttachment);
- attachmentList << attachment;
+ if(QFile::exists(editorAttachmentList.at(i)->path()))
+ {
+ ConvergedMessageAttachment* attachment =
+ new ConvergedMessageAttachment(
+ editorAttachmentList.at(i)->path(),
+ ConvergedMessageAttachment::EAttachment);
+ attachmentList << attachment;
+ }
+ else
+ {
+ mAttachmentContainer->deleteAttachment(editorAttachmentList.at(i));
+ errorCode = KErrNotFound;
+ }
}
}
if(attachmentList.count() > 0)
{
msg.addAttachments(attachmentList);
}
+ return errorCode;
}
int MsgUnifiedEditorView::saveContentToDrafts()
@@ -1165,8 +1223,25 @@
return INVALID_MSGID;
}
ConvergedMessage msg;
- packMessage(msg, true);
+ int result = packMessage(msg, true);
+ if(result == KErrNotFound)
+ {
+ HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS);
+ if(messageType == ConvergedMessage::Sms &&
+ addresses.isEmpty() &&
+ MsgUnifiedEditorMonitor::bodySize() <= 0 &&
+ MsgUnifiedEditorMonitor::containerSize() <= 0)
+ {
+ if(mOpenedMessageId.getId() != -1)
+ {
+ pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
+ }
+ // if empty msg, do not save
+ deactivateInputBlocker();
+ return INVALID_MSGID;
+ }
+ }
// save to drafts
MsgSendUtil *sendUtil = new MsgSendUtil(this);
int msgId = sendUtil->saveToDrafts(msg);
@@ -1191,6 +1266,17 @@
return msgId;
}
+bool MsgUnifiedEditorView::handleKeyEvent(int key)
+{
+ bool eventHandled = false;
+ if (Qt::Key_Yes == key && mSendAction->isEnabled()) {
+ eventHandled = true;
+ send();
+ }
+
+ return eventHandled;
+}
+
void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
{
Q_UNUSED(event)
@@ -1218,22 +1304,31 @@
QContactManager* contactManager = new QContactManager("symbian");
CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value);
int cntCount = cntServicesContacts.count();
+
+ QCRITICAL_WRITE_FORMAT("servicecontactlist count:",cntCount);
+
QList<QtMobility::QContact> contactList;
for(int i = 0; i < cntCount; i++ )
- {
+ {
contactList << contactManager->contact( cntServicesContacts.at(i).mContactId );
}
delete contactManager;
-
+
// get list of all versit-documents
QVersitDocument::VersitType versitType(QVersitDocument::VCard21Type);
- QVersitContactExporter* exporter = new QVersitContactExporter();
+
+ QVersitContactExporter exporter;
+ bool ret_val = exporter.exportContacts(contactList, versitType);
- bool ret_val = exporter->exportContacts(contactList, versitType);
- QList<QtMobility::QVersitDocument> documentList = exporter->documents();
-
- delete exporter;
-
+ if(ret_val == false)
+ {
+ QCRITICAL_WRITE("QVersitContactExporter::exportContacts returned false");
+ return KErrGeneral;
+ }
+
+ // process the documents
+ QList<QtMobility::QVersitDocument> documentList = exporter.documents();
+
// loop though and create a vcard for each contact
QVersitWriter* writer = new QVersitWriter();
for(int i = 0; i < cntCount; i++ )
@@ -1258,17 +1353,29 @@
// trap ignore so that, incase of multiselection, other vcards are still created
QByteArray bufArr;
TRAP_IGNORE(
- CBufBase* contactbufbase = CBufFlat::NewL(contactsbuf.size());
- CleanupStack::PushL(contactbufbase);
- contactbufbase->InsertL( contactbufbase->Size(),
- *XQConversions::qStringToS60Desc8( contactsbuf.data() ) );
- TPtr8 ptrbuf(contactbufbase->Ptr(0));
- bufArr = XQConversions::s60Desc8ToQByteArray(ptrbuf);
- CleanupStack::PopAndDestroy(contactbufbase);
- );
- file.write(bufArr);
- file.close();
- filelist << filepath;
+ HBufC8* contactBuf8 = XQConversions::qStringToS60Desc8(contactsbuf.data());
+ if(contactBuf8)
+ {
+ CleanupStack::PushL(contactBuf8);
+ CBufBase* contactbufbase = CBufFlat::NewL(contactsbuf.size());
+ CleanupStack::PushL(contactbufbase);
+
+ contactbufbase->InsertL( contactbufbase->Size(), *contactBuf8);
+
+ TPtr8 ptrbuf(contactbufbase->Ptr(0));
+ bufArr = XQConversions::s60Desc8ToQByteArray(ptrbuf);
+
+ CleanupStack::PopAndDestroy(contactbufbase);
+ CleanupStack::PopAndDestroy(contactBuf8);
+
+ // write to file
+ file.write(bufArr);
+ filelist << filepath;
+ }
+ ); // TRAP END
+
+ //close file
+ file.close();
}
}
}
@@ -1361,25 +1468,26 @@
//---------------------------------------------------------------
void MsgUnifiedEditorView::fetchContacts()
{
- QList<QVariant> args;
- QString serviceName("com.nokia.services.phonebookservices");
- QString operation("fetch(QString,QString,QString)");
+ QString service("phonebookservices");
+ QString interface("com.nokia.symbian.IContactsFetch");
+ QString operation("multiFetch(QString,QString)");
XQAiwRequest* request;
XQApplicationManager appManager;
- request = appManager.create(serviceName, "Fetch", operation, true); //embedded
+ request = appManager.create(service, interface, operation, true); //embedded
if ( request == NULL )
{
QCRITICAL_WRITE("AIW-ERROR: NULL request");
- return;
+ return;
}
// Result handlers
- connect (request, SIGNAL(requestOk(const QVariant&)),
+ connect (request, SIGNAL(requestOk(const QVariant&)),
this, SLOT(contactsFetched(const QVariant&)));
- connect (request, SIGNAL(requestError(int,const QString&)),
+ connect (request, SIGNAL(requestError(int,const QString&)),
this, SLOT(serviceRequestError(int,const QString&)));
- args << QString(tr("Phonebook"));
+ QList<QVariant> args;
+ args << QString(tr("Phonebook"));
args << KCntActionAll;
args << KCntFilterDisplayAll;
@@ -1403,12 +1511,14 @@
XQAiwRequest* request = NULL;
XQApplicationManager appManager;
request = appManager.create(service,interface, operation, true);//embedded
- request->setSynchronous(true); // synchronous
+
if(!request)
{
QCRITICAL_WRITE("AIW-ERROR: NULL request");
return;
}
+
+ request->setSynchronous(true); // synchronous
connect(request, SIGNAL(requestOk(const QVariant&)),
this, SLOT(imagesFetched(const QVariant&)));
@@ -1429,11 +1539,18 @@
//---------------------------------------------------------------
void MsgUnifiedEditorView::fetchAudio()
{
- // Launch Audio fetcher view
- QVariantList params;
- params << MsgBaseView::AUDIOFETCHER; // target view
- params << MsgBaseView::UNIEDITOR; // source view
- emit switchView(params);
+ // Launch Audio fetcher dialog
+ if(!mDialog)
+ {
+ mDialog = new MsgAudioFetcherDialog();
+ connect(mDialog,
+ SIGNAL(audioSelected(QString&)),
+ this,
+ SLOT(onAudioSelected(QString&)));
+ }
+
+ //show the dialog
+ mDialog->show();
}
//---------------------------------------------------------------
@@ -1550,6 +1667,20 @@
connect(mVkbHost,SIGNAL(aboutToOpen()),
this,SLOT(vkbAboutToOpen()));
}
+
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::onAudioSelected
+// @see header file
+//---------------------------------------------------------------
+void
+MsgUnifiedEditorView::onAudioSelected(QString& filePath)
+{
+ if (!filePath.isEmpty())
+ {
+ mBody->setAudio(filePath);
+ }
+}
+
//---------------------------------------------------------------
// MsgUnifiedEditorView::hideChrome
//
@@ -1750,4 +1881,60 @@
delete tempAddr;
}
}
+
+// ----------------------------------------------------------------------------
+// MsgUnifiedEditorView::isReplyPathBroken
+// @see header
+// ----------------------------------------------------------------------------
+bool MsgUnifiedEditorView::isReplyPathBroken()
+{
+ // 1. Never set for MMS
+ // 2. if additional recipients exits
+ if( (MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms) ||
+ (mToField->addressCount() != 1) )
+ {
+ // broken
+ return true;
+ }
+
+ // 3. if only recipient is not same as originating SME
+ QString dispName;
+ int phCount;
+ int origCntLocalId = MsgContactHandler::resolveContactDisplayName(
+ mOriginatingSME, dispName, phCount);
+ int currCntLocalId = -1;
+ QString currAddress(mToField->addresses().at(0)->address());
+ if(origCntLocalId != -1)
+ {
+ currCntLocalId = MsgContactHandler::resolveContactDisplayName(
+ currAddress, dispName, phCount);
+ }
+
+ if(currCntLocalId != -1)
+ { // both are mapped contacts present in contacts db
+ if(currCntLocalId != origCntLocalId)
+ {
+ return true;
+ }
+ }
+ else
+ { // atleast one contact is not present in contacts db
+ // direct compare
+ UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
+ bool compareResult = false;
+ TRAP_IGNORE(
+ compareResult = genUtils->MatchPhoneNumberL(
+ *XQConversions::qStringToS60Desc(mOriginatingSME),
+ *XQConversions::qStringToS60Desc(currAddress))
+ );
+ delete genUtils;
+ if(!compareResult)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
//EOF