messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
changeset 44 36f374c67aa8
parent 43 35b64624a9e7
child 47 5b14749788d7
child 52 12db4185673b
--- a/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -49,7 +49,7 @@
 #include <qcontactmanager.h>
 #include <qversitcontactexporter.h>
 #include <cntservicescontact.h>
-
+#include <commonphoneparser.h>      // Common phone number validity checker
 
 // USER INCLUDES
 #include "debugtraces.h"
@@ -94,26 +94,23 @@
 //options menu.
 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
-#define LOC_PRIORITY        hbTrId("txt_messaging_setlabel_priority")
-#define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options")
+#define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
 #define LOC_DELETE_MESSAGE  hbTrId("txt_messaging_opt_delete_message")
 
 //priority sub menu
-#define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high")
-#define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal")
-#define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low")
+#define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
+#define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
+#define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
 
 //group box
 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
+#define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
 
 //saved to draft note
 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
 
 //delete confermation
 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
-#define LOC_BUTTON_DELETE       hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL       hbTrId("txt_common_button_cancel")
-#define LOC_DIALOG_OK           hbTrId("txt_common_button_ok")
 
 // attachment addition failure note
 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
@@ -202,7 +199,8 @@
     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
     mMainLayout->setSpacing(vItemSpacing);
 
-    mMsgMonitor = new MsgUnifiedEditorMonitor(this);    
+    mMsgMonitor = new MsgUnifiedEditorMonitor(this);
+    connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool)));
 
     mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
     
@@ -255,7 +253,6 @@
     HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
     lowPriorityAction->setData(ConvergedMessage::Low);
 
-    HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS);
     HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
 
     connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
@@ -263,7 +260,6 @@
     connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
     connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
     connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
-    connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions()));
     connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
 
     setMenu(mainMenu);
@@ -562,6 +558,7 @@
     attachAction->setIcon(HbIcon(ATTACH_ICON));
     
     mTBExtnContentWidget = new HbListWidget();
+    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
     mTBExtnContentWidget->addItem(LOC_PHOTO);
     mTBExtnContentWidget->addItem(LOC_SOUND);
     mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
@@ -579,7 +576,7 @@
 
     //Add Action to the toolbar and show toolbar
     mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
-
+    mSendAction->setDisabled(true);
 
     setToolBar(toolBar);
 }
@@ -659,7 +656,7 @@
     groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
     
     groupBox->setContentWidget(groupWidget);
-    groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
+    groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
     mMainLayout->insertItem(1,groupBox);
     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
     
@@ -692,13 +689,16 @@
     {
         if(!state)
         {
-           groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
+           groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
         }
         else
         {
             int addrCount = mCcField->addressCount();
             addrCount += mBccField->addressCount();
-            groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));
+            if(addrCount > 0)
+            {
+                groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));    
+            }
         }
     }
 }
@@ -718,14 +718,11 @@
     mSubjectField->setPriority(priority);
 }
 
-void MsgUnifiedEditorView::sendingOptions()
-{
-}
-
 void MsgUnifiedEditorView::deleteMessage()
 {
-    HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
-                                            LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
+    HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,
+                           SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 void MsgUnifiedEditorView::removeAttachmentContainer()
@@ -758,6 +755,12 @@
 
 int MsgUnifiedEditorView::addAttachment(const QString& filepath)
 {
+    // do nothing if filepath is empty
+    if(filepath.isEmpty())
+    {
+        return MsgAttachmentContainer::EAddSuccess;
+    }
+
     if(!mAttachmentContainer)
     {
         mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
@@ -916,16 +919,14 @@
             if (messageType == ConvergedMessage::Sms)
             {
                 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
-                    this,SLOT(onDialogSmsSettings(HbAction*)),
-                                                 LOC_DIALOG_OK,
-                                                 LOC_BUTTON_CANCEL);
+                                       this,SLOT(onDialogSmsSettings(HbAction*)),
+                                       HbMessageBox::Ok | HbMessageBox::Cancel);
             }
             else
             {
                 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
-                    this,SLOT(onDialogMmsSettings(HbAction*)),                             
-                                                 LOC_DIALOG_OK,
-                                                 LOC_BUTTON_CANCEL);
+                                       this,SLOT(onDialogMmsSettings(HbAction*)),                             
+                                       HbMessageBox::Ok | HbMessageBox::Cancel);
             }
         }
     }
@@ -942,7 +943,13 @@
             mToField->addresses(removeDuplicates);
     ConvergedMessageAddressList ccAddresses;
     ConvergedMessageAddressList bccAddresses;
-
+    
+	//Don't format the addresses for save to drfats case
+	if(!isSave)
+	{
+       formatAddresses(addresses);
+    }
+	
     msg.addToRecipients(addresses);
     msg.setBodyText(mBody->text());
     msg.setDirection(ConvergedMessage::Outgoing);
@@ -1001,10 +1008,20 @@
 
         if(ccAddresses.count()>0)
         {
+		//Don't format the addresses for save to drfats case
+	    if(!isSave)
+	    {
+           formatAddresses(ccAddresses);
+        }        
         msg.addCcRecipients(ccAddresses);
         }
         if(bccAddresses.count()>0)
         {
+		//Don't format the addresses for save to drfats case
+	    if(!isSave)
+	    {
+           formatAddresses(bccAddresses);        
+		}
         msg.addBccRecipients(bccAddresses);
         }
         if(mSubjectField)
@@ -1660,4 +1677,32 @@
         }
     }
 
+// ----------------------------------------------------------------------------
+// MsgUnifiedEditorView::formatAddresses
+// @see header
+// ----------------------------------------------------------------------------
+void MsgUnifiedEditorView::formatAddresses(
+        ConvergedMessageAddressList& addresses)
+{       
+
+    for(int i=0; i < addresses.count() ;i++ )
+    {
+        QString addr = addresses[i]->address();
+        
+        HBufC *tempAddr = XQConversions::qStringToS60Desc(addr);     
+            
+        TPtr ptr = tempAddr->Des();
+                    
+         // Note: This is just to parse spaces etc away from phonenumbers.
+         //       Ignore EFalse returned for email addresses.   
+        CommonPhoneParser::ParsePhoneNumber(ptr , 
+                                            CommonPhoneParser::ESMSNumber );        
+       
+        addr = XQConversions::s60DescToQString(tempAddr->Des()); 
+        
+        addresses[i]->setAddress(addr);
+        
+        delete tempAddr;                                                       
+    }       
+}
 //EOF