--- a/messagingapp/msgui/unifiededitor/src/msgunieditormonitor.cpp Tue Oct 05 13:58:47 2010 +0530
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditormonitor.cpp Tue Oct 19 11:30:16 2010 +0530
@@ -18,28 +18,27 @@
// INCLUDES
#include "debugtraces.h"
#include <HbNotificationDialog>
-#include <HbWidget>
// USER INCLUDES
#include "msgunieditormonitor.h"
-#include "msgunieditorview.h"
-#include "msgunieditoraddress.h"
-#include "msgunieditorsubject.h"
-#include "msgunieditorbody.h"
-#include "msgunieditorattachmentcontainer.h"
#include "UniEditorGenUtils.h"
// Constants
// Define static
-ConvergedMessage::MessageType MsgUnifiedEditorMonitor::mMessageType;
-int MsgUnifiedEditorMonitor::mBodySize;
-int MsgUnifiedEditorMonitor::mContainerSize;
-int MsgUnifiedEditorMonitor::mSubjectSize;
-int MsgUnifiedEditorMonitor::mMaxMmsSize;
-int MsgUnifiedEditorMonitor::mMaxSmsRecipients;
-int MsgUnifiedEditorMonitor::mMaxMmsRecipients;
-int MsgUnifiedEditorMonitor::mMsgCurrAddressCount;
+ConvergedMessage::MessageType MsgUnifiedEditorMonitor::mMessageType = ConvergedMessage::Sms;
+int MsgUnifiedEditorMonitor::mBodySize = 0;
+int MsgUnifiedEditorMonitor::mBodyTextSize = 0;
+int MsgUnifiedEditorMonitor::mContainerSize = 0;
+int MsgUnifiedEditorMonitor::mBodyContentSize = 0;
+int MsgUnifiedEditorMonitor::mSubjectSize = 0;
+int MsgUnifiedEditorMonitor::mMaxMmsSize = 0;
+int MsgUnifiedEditorMonitor::mMaxSmsRecipients = 0;
+int MsgUnifiedEditorMonitor::mMaxMmsRecipients = 0;
+int MsgUnifiedEditorMonitor::mToAddressCount = 0;
+int MsgUnifiedEditorMonitor::mCcAddressCount = 0;
+int MsgUnifiedEditorMonitor::mBccAddressCount = 0;
+bool MsgUnifiedEditorMonitor::mReadyForSend = false;
//Localized strings
#define LOC_POP_MESSAGE_CHANGE_MUL hbTrId("txt_messaging_dpopinfo_message_type_changed_to_mul")
@@ -51,7 +50,12 @@
//---------------------------------------------------------------
MsgUnifiedEditorMonitor::MsgUnifiedEditorMonitor(QObject* parent) :
QObject(parent),
-mSkipNote(false)
+mSkipNote(false),
+mContainerHasMmsContent(false),
+mPriority(ConvergedMessage::Normal),
+mEmailPresent(false),
+mUniCode(false),
+mImageResizing(false)
{
mUniEditorGenUtils = q_check_ptr( new UniEditorGenUtils);
init();
@@ -63,22 +67,39 @@
//---------------------------------------------------------------
MsgUnifiedEditorMonitor::~MsgUnifiedEditorMonitor()
{
+ reset();
delete mUniEditorGenUtils;
}
//---------------------------------------------------------------
+// MsgUnifiedEditorMonitor::reset
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorMonitor::reset()
+{
+ mMessageType = ConvergedMessage::Sms;
+ mBodySize = 0;
+ mBodyTextSize = 0;
+ mContainerSize = 0;
+ mBodyContentSize = 0;
+ mSubjectSize = 0;
+ mMaxMmsSize = 0;
+ mMaxSmsRecipients = 0;
+ mMaxMmsRecipients = 0;
+ mToAddressCount = 0;
+ mCcAddressCount = 0;
+ mBccAddressCount = 0;
+ mReadyForSend = false;
+}
+
+//---------------------------------------------------------------
// MsgUnifiedEditorMonitor::init
// @see header file
//---------------------------------------------------------------
void MsgUnifiedEditorMonitor::init()
{
- mMessageType = ConvergedMessage::Sms;
- mBodySize = 0;
- mContainerSize = 0;
- mSubjectSize = 0;
- mMsgCurrAddressCount = 0;
-
mMaxMmsSize = KDefaultMaxSize;
+
TRAP_IGNORE(mMaxMmsSize = mUniEditorGenUtils->MaxMmsMsgSizeL());
mMaxSmsRecipients = KDefaultSmsRecipients;
@@ -89,11 +110,69 @@
}
//---------------------------------------------------------------
-// MsgUnifiedEditorMonitor::handleContentChange
+// MsgUnifiedEditorMonitor::handleContentsChanged
// @see header file
//---------------------------------------------------------------
-void MsgUnifiedEditorMonitor::handleContentChange()
+void MsgUnifiedEditorMonitor::handleContentsChanged(const QVariant& data)
{
+ QString objectName = sender()->objectName();
+
+ if(objectName == "attachmentContainer")
+ {
+ QVariantList dataList = data.toList();
+ mContainerSize = dataList.at(0).toInt();
+ mContainerHasMmsContent = dataList.at(1).toBool();
+ }
+
+ if(objectName == "body")
+ {
+ if(data.type() == QVariant::Bool)
+ {
+ mImageResizing = data.toBool();
+ }
+ else
+ {
+ mBodySize = data.toInt();
+ updateBodyContentSize();
+ }
+ }
+
+ if(objectName == "bodyText")
+ {
+ QVariantList dataList = data.toList();
+ mBodyTextSize = dataList.at(0).toInt();
+ mUniCode = dataList.at(1).toBool();
+ updateBodyContentSize();
+
+ }
+
+ if(objectName == "subject")
+ {
+ QVariantList dataList = data.toList();
+ mSubjectSize = dataList.at(0).toInt();
+ mPriority = ConvergedMessage::Priority(dataList.at(1).toInt());
+
+ }
+
+ if(objectName == "to")
+ {
+ QVariantList dataList = data.toList();
+ mToAddressCount = dataList.at(0).toInt();
+ mEmailPresent = dataList.at(1).toBool();
+ }
+
+ if(objectName == "cc")
+ {
+ QVariantList dataList = data.toList();
+ mCcAddressCount = dataList.at(0).toInt();
+ }
+
+ if(objectName == "bcc")
+ {
+ QVariantList dataList = data.toList();
+ mBccAddressCount = dataList.at(0).toInt();
+ }
+
// get the projected message type & show the type change note
ConvergedMessage::MessageType newMsgType = projectedMsgType();
if(mMessageType != newMsgType)
@@ -110,10 +189,14 @@
}
showPopup(noteStr);
}
-
- HbWidget* senderWidget = qobject_cast<HbWidget*>(sender());
- updateMsgInfo(senderWidget);
+
updateSend();
+
+ //emit when content is modified after opening a draft message.
+ if(!mSkipNote)
+ {
+ emit contentsChanged();
+ }
}
//---------------------------------------------------------------
@@ -136,66 +219,6 @@
}
//---------------------------------------------------------------
-// MsgUnifiedEditorMonitor::updateMsgInfo
-// @see header file
-//---------------------------------------------------------------
-void MsgUnifiedEditorMonitor::updateMsgInfo(HbWidget* senderWidget)
-{
- if(mMessageType == ConvergedMessage::Mms)
- {
- //Disable char counter & add subject
- view()->mBody->disableCharCounter();
- view()->addSubject();
- }
- else
- {
- //Enable char counter
- view()->mBody->enableCharCounter();
- }
-
- // check if sent by body widget
- MsgUnifiedEditorBody* body = NULL;
- body = qobject_cast<MsgUnifiedEditorBody*>(senderWidget);
- if(body)
- {
- mBodySize = view()->mBody->bodySize();
- view()->setAttachOptionEnabled(
- MsgUnifiedEditorView::TBE_PHOTO, !view()->mBody->hasImage());
- view()->setAttachOptionEnabled(
- MsgUnifiedEditorView::TBE_SOUND, !view()->mBody->hasAudio());
- return;
- }
-
- // check if sent by subject widget
- MsgUnifiedEditorSubject* subject = NULL;
- subject = qobject_cast<MsgUnifiedEditorSubject*>(senderWidget);
- if(subject)
- {
- mSubjectSize = view()->mSubjectField->subjectSize();
- return;
- }
-
- // check if sent by attachment container widget
- MsgAttachmentContainer* container = NULL;
- container = qobject_cast<MsgAttachmentContainer*>(senderWidget);
- if(container)
- {
- mContainerSize = view()->mAttachmentContainer->containerSize();
- return;
- }
-
- // handle content change from other widgets e.g. To, Cc, Bcc address field
- int totalAddressCount = view()->mToField->addressCount();
- if(view()->mCcField && view()->mBccField)
- {
- totalAddressCount += view()->mCcField->addressCount() +
- view()->mBccField->addressCount();
- }
- mMsgCurrAddressCount = totalAddressCount;
- return;
-}
-
-//---------------------------------------------------------------
// MsgUnifiedEditorMonitor::showPopup
// @see header file
//---------------------------------------------------------------
@@ -215,37 +238,23 @@
}
//---------------------------------------------------------------
-// MsgUnifiedEditorMonitor::view
-// @see header file
-//---------------------------------------------------------------
-MsgUnifiedEditorView* MsgUnifiedEditorMonitor::view()
-{
- return static_cast<MsgUnifiedEditorView*>(this->parent());
-}
-
-//---------------------------------------------------------------
// MsgUnifiedEditorMonitor::bodyHasMMSContent
// @see header file
//---------------------------------------------------------------
bool MsgUnifiedEditorMonitor::bodyHasMMSContent()
{
- MsgUnifiedEditorBody* edBody = view()->mBody;
- // If any media-object is present inside body
- if(!edBody->mediaContent().isEmpty())
- {
- return true;
- }
-
- int bodyTextSize = mUniEditorGenUtils->UTF8Size(edBody->text());
+ bool result = false;
+
int maxSmsSize = 0;
- TRAP_IGNORE(maxSmsSize =
- mUniEditorGenUtils->MaxSmsMsgSizeL(edBody->isUnicode()));
+ TRAP_IGNORE(maxSmsSize = mUniEditorGenUtils->MaxSmsMsgSizeL(mUniCode));
+
// If body text size exceeds sms text-size limit
- if(bodyTextSize > maxSmsSize)
+ if( mBodyTextSize > maxSmsSize || mBodySize)
{
- return true;
+ result = true;
}
- return false;
+
+ return result;
}
//---------------------------------------------------------------
@@ -254,22 +263,13 @@
//---------------------------------------------------------------
bool MsgUnifiedEditorMonitor::subjectHasMMSContent()
{
- MsgUnifiedEditorSubject* edSubject = view()->mSubjectField;
- ConvergedMessage::Priority priority = ConvergedMessage::Normal;
- QString subjectText;
- if(edSubject)
+ bool result = false;
+ if(mPriority != ConvergedMessage::Normal || mSubjectSize)
{
- priority = edSubject->priority();
- subjectText = edSubject->text();
+ result = true;
}
- // If priority is set to other than Normal or
- // If subject has some content
- if( (priority != ConvergedMessage::Normal) ||
- !subjectText.isEmpty() )
- {
- return true;
- }
- return false;
+
+ return result;
}
//---------------------------------------------------------------
@@ -278,23 +278,14 @@
//---------------------------------------------------------------
bool MsgUnifiedEditorMonitor::containerHasMMSContent()
{
- QString bodyText = view()->mBody->text();
- MsgAttachmentContainer* edContainer = view()->mAttachmentContainer;
- bool hasMMAttachmentContent = false;
- int attachmentCount = 0;
- if(edContainer)
+ bool result = false;
+
+ if(mContainerHasMmsContent || mContainerSize && mBodyTextSize)
{
- hasMMAttachmentContent = edContainer->hasMMContent();
- attachmentCount = edContainer->count();
+ result = true;
}
- // If MM attachments are present or
- // If only one non-MM attachment is present e.g. vcf along with body text
- if( hasMMAttachmentContent ||
- ((attachmentCount == 1) && !bodyText.isEmpty()) )
- {
- return true;
- }
- return false;
+
+ return result;
}
//---------------------------------------------------------------
@@ -303,32 +294,14 @@
//---------------------------------------------------------------
bool MsgUnifiedEditorMonitor::otherMMSCriteriaMet()
{
- MsgUnifiedEditorAddress* edCc = view()->mCcField;
- MsgUnifiedEditorAddress* edBcc = view()->mBccField;
- int ccCount = 0;
- int bccCount = 0;
- if(edCc && edBcc)
+ bool result = false;
+
+ if(mCcAddressCount || mBccAddressCount || mEmailPresent ||
+ mToAddressCount > mMaxSmsRecipients)
{
- ccCount = edCc->addressCount();
- bccCount = edBcc->addressCount();
+ result = true;
}
- // If CC/BCC has some content or
- // If to-recipients count exceeds max sms recipient count
- if( ccCount || bccCount ||
- (view()->mToField->addressCount() > mMaxSmsRecipients) )
- {
- return true;
- }
-
- // If to-field contains an email address
- bool isEmailPresent = false;
- ConvergedMessageAddressList addrList = view()->mToField->addresses();
- TRAP_IGNORE(isEmailPresent = mUniEditorGenUtils->VerifyEmailAddressesL(addrList));
- if(isEmailPresent)
- {
- return true;
- }
- return false;
+ return result;
}
//---------------------------------------------------------------
@@ -337,15 +310,33 @@
//---------------------------------------------------------------
void MsgUnifiedEditorMonitor::updateSend()
{
- if (mMsgCurrAddressCount > 0 && (mSubjectSize + mBodySize + mContainerSize) > 0 && !view()->mBody->isImageResizing())
+
+ if ( (mToAddressCount + mCcAddressCount + mBccAddressCount) > 0 &&
+ (mSubjectSize + mBodyContentSize + mContainerSize) > 0 &&
+ !mImageResizing )
{
emit enableSend(true);
+ mReadyForSend = true;
}
else
{
emit enableSend(false);
+ mReadyForSend = false;
+ }
+
+}
+
+void MsgUnifiedEditorMonitor::updateBodyContentSize()
+{
+ if(mBodySize || mBodyTextSize)
+ {
+ mBodyContentSize = mBodySize + mBodyTextSize + KEstimatedMimeHeaderSize
+ + KEstimatedMmsSmilHeaderSize;
+ }
+ else
+ {
+ mBodyContentSize = 0;
}
}
-
//EOF