messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 38 4e4b6adb1024
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    34 #include <HbFrameBackground>
    34 #include <HbFrameBackground>
    35 #include <HbListViewItem>
    35 #include <HbListViewItem>
    36 #include <HbListWidgetItem>
    36 #include <HbListWidgetItem>
    37 #include <HbNotificationDialog>
    37 #include <HbNotificationDialog>
    38 #include <HbMessageBox>
    38 #include <HbMessageBox>
       
    39 #include <HbAbstractVkbHost>
       
    40 #include <HbMainWindow>
    39 #include <xqaiwrequest.h>
    41 #include <xqaiwrequest.h>
    40 #include <xqappmgr.h>
    42 #include <xqappmgr.h>
    41 
    43 #include <HbStyleLoader>
    42 // QT Mobility for fetching business card
    44 // QT Mobility for fetching business card
       
    45 #include <qmobilityglobal.h>
    43 #include <qversitwriter.h>
    46 #include <qversitwriter.h>
    44 #include <qversitdocument.h>
    47 #include <qversitdocument.h>
    45 #include <qcontact.h>
    48 #include <qcontact.h>
    46 #include <qcontactmanager.h>
    49 #include <qcontactmanager.h>
    47 #include <qversitcontactexporter.h>
    50 #include <qversitcontactexporter.h>
    48 #include <cntservicescontact.h>
    51 #include <cntservicescontact.h>
    49 
    52 
       
    53 
    50 // USER INCLUDES
    54 // USER INCLUDES
    51 #include "debugtraces.h"
    55 #include "debugtraces.h"
    52 #include "msgunieditorview.h"
    56 #include "msgunieditorview.h"
    53 #include "msgunieditoraddress.h"
    57 #include "msgunieditoraddress.h"
    54 #include "msgunieditorsubject.h"
    58 #include "msgunieditorsubject.h"
    55 #include "msgunieditorbody.h"
    59 #include "msgunieditorbody.h"
    56 #include "msgmonitor.h"
    60 #include "msgunieditormonitor.h"
    57 #include "msgattachmentcontainer.h"
    61 #include "msgunieditorattachmentcontainer.h"
    58 #include "msgsendutil.h"
    62 #include "msgsendutil.h"
    59 #include "convergedmessageaddress.h"
    63 #include "convergedmessageaddress.h"
    60 #include "unieditorgenutils.h"
    64 #include "UniEditorGenUtils.h"
    61 #include "unieditorpluginloader.h"
    65 #include "unieditorpluginloader.h"
    62 #include "unieditorplugininterface.h"
    66 #include "unieditorplugininterface.h"
    63 
    67 #include "msgsettingsview.h"
       
    68 
       
    69 QTM_USE_NAMESPACE
    64 // Constants
    70 // Constants
    65 const QString SEND_ICON("qtg_mono_send");
    71 const QString SEND_ICON("qtg_mono_send");
    66 const QString ATTACH_ICON("qtg_mono_attach");
    72 const QString ATTACH_ICON("qtg_mono_attach");
    67 // temporary folder for unieditor
    73 // temporary folder for unieditor
    68 const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor");
    74 const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor");
    86 #define LOC_BUSINESS_CARD   hbTrId("txt_messaging_button_business_card")
    92 #define LOC_BUSINESS_CARD   hbTrId("txt_messaging_button_business_card")
    87 
    93 
    88 //options menu.
    94 //options menu.
    89 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    95 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    90 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
    96 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
    91 #define LOC_PRIORITY        hbTrId("txt_messaging_setlabel_priority")
    97 #define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
    92 #define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options")
       
    93 #define LOC_DELETE_MESSAGE  hbTrId("txt_messaging_opt_delete_message")
    98 #define LOC_DELETE_MESSAGE  hbTrId("txt_messaging_opt_delete_message")
    94 
    99 
    95 //priority sub menu
   100 //priority sub menu
    96 #define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high")
   101 #define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
    97 #define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal")
   102 #define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
    98 #define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low")
   103 #define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
    99 
   104 
   100 //group box
   105 //group box
   101 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
   106 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
       
   107 #define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
   102 
   108 
   103 //saved to draft note
   109 //saved to draft note
   104 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
   110 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
   105 
   111 
   106 //delete confermation
   112 //delete confermation
   107 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
   113 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
   108 #define LOC_BUTTON_DELETE       hbTrId("txt_common_button_delete")
   114 
   109 #define LOC_BUTTON_CANCEL       hbTrId("txt_common_button_cancel")
   115 // attachment addition failure note
   110 #define LOC_DIALOG_OK           hbTrId("txt_common_button_ok")
   116 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
   111 
   117 
   112 //extension list item frame.
   118 //extension list item frame.
   113 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
   119 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
   114 
   120 
       
   121 //settings confirmation
       
   122 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
       
   123 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined")
   115 // LOCAL FUNCTIONS
   124 // LOCAL FUNCTIONS
   116 QString editorTempPath();
   125 
       
   126 //---------------------------------------------------------------
       
   127 // editorTempPath
       
   128 // @return fullPath of unified editor's temporary dir
       
   129 //---------------------------------------------------------------
       
   130 QString editorTempPath()
       
   131 {
       
   132     QDir tempDir;
       
   133     QString tempPath(QDir::toNativeSeparators(tempDir.tempPath()));
       
   134     tempPath.append(QDir::separator());
       
   135     tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER);
       
   136     tempPath.append(QDir::separator());
       
   137     return tempPath;
       
   138 }
   117 
   139 
   118 //---------------------------------------------------------------
   140 //---------------------------------------------------------------
   119 // MsgUnifiedEditorView::MsgUnifiedEditorView
   141 // MsgUnifiedEditorView::MsgUnifiedEditorView
   120 // @see header file
   142 // @see header file
   121 //---------------------------------------------------------------
   143 //---------------------------------------------------------------
   122 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
   144 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
   123     MsgBaseView(parent),
   145     MsgBaseView(parent),
   124     mSubjectAction(0),
   146     mSubjectAction(0),
   125     mCcBccAction(0),
   147     mCcBccAction(0),
       
   148     mSendAction(0),
   126     mMainLayout(0),
   149     mMainLayout(0),
   127     mSubjectField(0),
   150     mSubjectField(0),
   128     mToField(0),
   151     mToField(0),
   129     mCcField(0),
   152     mCcField(0),
   130     mBccField(0),
   153     mBccField(0),
   131     mBody(0),
   154     mBody(0),
   132     mContentWidget(0),
   155     mContentWidget(0),
   133     mMsgMonitor(0),    
   156     mMsgMonitor(0),    
   134     mAttachmentContainer(0),
   157     mAttachmentContainer(0),
   135     mPluginLoader(0),
   158     mPluginLoader(0),
   136     mCanSaveToDrafts(true)
   159     mCanSaveToDrafts(true),
   137     {
   160     mVkbHost(NULL)
   138     addMenu();
   161     {
       
   162     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
       
   163     
   139     addToolBar();
   164     addToolBar();
   140 
   165     initView();
       
   166     }
       
   167 
       
   168 //---------------------------------------------------------------
       
   169 // MsgUnifiedEditorView::~MsgUnifiedEditorView
       
   170 // @see header file
       
   171 //---------------------------------------------------------------
       
   172 MsgUnifiedEditorView::~MsgUnifiedEditorView()
       
   173 {
       
   174     // clean editor's temporary contents before exiting
       
   175     removeTempFolder();
       
   176 }
       
   177 
       
   178 //---------------------------------------------------------------
       
   179 // MsgUnifiedEditorView::initView
       
   180 // @see header file
       
   181 //---------------------------------------------------------------
       
   182 void MsgUnifiedEditorView::initView()
       
   183 {
       
   184     if (!HbStyleLoader::registerFilePath(":/layouts")) {
       
   185         QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath");
       
   186     }
   141     HbScrollArea* scrollArea = new HbScrollArea(this);
   187     HbScrollArea* scrollArea = new HbScrollArea(this);
   142     this->setWidget(scrollArea);
   188     this->setWidget(scrollArea);
   143 
   189 
   144     mContentWidget = new HbWidget(this);
   190     mContentWidget = new HbWidget(this);
   145     scrollArea->setContentWidget(mContentWidget);
   191     scrollArea->setContentWidget(mContentWidget);
   146 
       
   147     mPluginPath = pluginPath(); 
       
   148 
   192 
   149     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget);
   193     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget);
   150     qreal vTopSpacing = 0.0;
   194     qreal vTopSpacing = 0.0;
   151     qreal vItemSpacing = 0.0;
   195     qreal vItemSpacing = 0.0;
   152     style()->parameter("hb-param-margin-gene-top",vTopSpacing);    
   196     style()->parameter("hb-param-margin-gene-top",vTopSpacing);    
   153     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   197     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   154     
   198     
   155     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
   199     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
   156     mMainLayout->setSpacing(vItemSpacing);
   200     mMainLayout->setSpacing(vItemSpacing);
   157 
   201 
   158     mMsgMonitor = new MsgMonitor(this);    
   202     mMsgMonitor = new MsgUnifiedEditorMonitor(this);
   159 
   203     connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool)));
   160     mToField = new MsgUnifiedEditorAddress( LOC_TO, mPluginPath, mContentWidget );
   204 
   161     mBody = new MsgUnifiedEditorBody(mPluginPath, mContentWidget);
   205     mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
       
   206     
       
   207     mBody = new MsgUnifiedEditorBody( mContentWidget);
   162 
   208 
   163     mMainLayout->addItem(mToField);
   209     mMainLayout->addItem(mToField);
   164     mMainLayout->addItem(mBody);
   210     mMainLayout->addItem(mBody);
   165  
   211  
   166     //Set the invalid msg id
   212     //Set the invalid msg id
   167     mOpenedMessageId.setId(-1);
   213     mOpenedMessageId.setId(-1);
   168 
   214 
   169     // create editor's temp folder
       
   170     QDir tempDir = QDir(QString());
       
   171     QString tempPath(editorTempPath());
       
   172     if(tempDir.mkpath(tempPath))
       
   173     {
       
   174         tempDir.cd(tempPath);
       
   175         // remove stale folder content when freshly launched
       
   176         QStringList contentList(tempDir.entryList());
       
   177         int contentCount = contentList.count();
       
   178         for(int i=0; i<contentCount; i++)
       
   179         {
       
   180             tempDir.remove(contentList.at(i));
       
   181         }
       
   182     }
       
   183 
       
   184     connect(mToField, SIGNAL(sendMessage()), this, SLOT(send()));
   215     connect(mToField, SIGNAL(sendMessage()), this, SLOT(send()));
       
   216     connect(mToField, SIGNAL(contentChanged()),
       
   217             mMsgMonitor, SLOT(handleContentChange()));
       
   218     connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
       
   219     
   185     connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
   220     connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
       
   221     connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
   186     connect(mBody, SIGNAL(contentChanged()),
   222     connect(mBody, SIGNAL(contentChanged()),
   187             mMsgMonitor, SLOT(checkMsgTypeChange()));
   223             mMsgMonitor, SLOT(handleContentChange()));
   188     }
   224     connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool)));    
   189 
   225     
   190 //---------------------------------------------------------------
       
   191 // MsgUnifiedEditorView::~MsgUnifiedEditorView
       
   192 // @see header file
       
   193 //---------------------------------------------------------------
       
   194 MsgUnifiedEditorView::~MsgUnifiedEditorView()
       
   195 {
       
   196     // clean editor's temporary contents before exiting
       
   197     QDir tempDir = QDir(QString());
       
   198     QString tempPath(editorTempPath());
       
   199     tempDir.cd(tempPath);
       
   200     QStringList contentList(tempDir.entryList());
       
   201     int contentCount = contentList.count();
       
   202     for(int i=0; i<contentCount; i++)
       
   203     {
       
   204         tempDir.remove(contentList.at(i));
       
   205     }
       
   206     tempDir.cdUp();
       
   207     tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER);
       
   208 }
   226 }
   209 
   227 
   210 void MsgUnifiedEditorView::addMenu()
   228 void MsgUnifiedEditorView::addMenu()
   211 {
   229 {
   212     //Create Menu Options
   230     //Create Menu Options
   213     HbMenu* mainMenu = new HbMenu();
   231     HbMenu* mainMenu = new HbMenu();
   214 
   232     mainMenu->setFocusPolicy(Qt::NoFocus);
   215     //TODO:These 2 should be submenu option to Add
   233 	
   216     mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT);
   234     //if subject field / cc,bcc fields are already present don't add corresponding actions.
   217     mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC);
   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     }
   218     
   244     
   219     HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY);
   245     HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY);
   220 
   246 
   221     HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH);
   247     HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH);
   222     highPriorityAction->setData(ConvergedMessage::High);
   248     highPriorityAction->setData(ConvergedMessage::High);
   225     normalPriorityAction->setData(ConvergedMessage::Normal);
   251     normalPriorityAction->setData(ConvergedMessage::Normal);
   226 
   252 
   227     HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
   253     HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
   228     lowPriorityAction->setData(ConvergedMessage::Low);
   254     lowPriorityAction->setData(ConvergedMessage::Low);
   229 
   255 
   230     HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS);
       
   231     HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
   256     HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
   232 
   257 
   233     connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
   258     connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
   234     connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
   259     connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
   235     connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   260     connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   236     connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   261     connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   237     connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   262     connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
   238     connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions()));
       
   239     connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
   263     connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
   240 
   264 
   241     setMenu(mainMenu);
   265     setMenu(mainMenu);
   242 }
   266 }
   243 
   267 
   269     msg = pluginInterface->convertFrom(messageId.getId());
   293     msg = pluginInterface->convertFrom(messageId.getId());
   270 
   294 
   271     if( msg != NULL )
   295     if( msg != NULL )
   272     {
   296     {
   273         //Populate the content inside editor
   297         //Populate the content inside editor
   274         populateContentIntoEditor(*msg);
   298         populateContentIntoEditor(*msg,true); // true as it is  draft message
   275         delete msg;
   299         delete msg;
   276     }
   300     }
       
   301     
       
   302     mCanSaveToDrafts = false;  
   277 }
   303 }
   278 
   304 
   279 void MsgUnifiedEditorView::forwardMessage(ConvergedMessageId& messageId,
   305 void MsgUnifiedEditorView::forwardMessage(ConvergedMessageId& messageId,
   280     ConvergedMessage::MessageType messageType )
   306     ConvergedMessage::MessageType messageType )
   281 {
   307 {
   326     }
   352     }
   327 
   353 
   328     // population logic based on editor Operation command
   354     // population logic based on editor Operation command
   329     switch(editorOp)
   355     switch(editorOp)
   330     {
   356     {
   331         case MsgBaseView::ADD_RECIPIENTS:
       
   332         {
       
   333             addCcBcc();
       
   334         }
       
   335         break;
       
   336         case MsgBaseView::ADD_SUBJECT:
   357         case MsgBaseView::ADD_SUBJECT:
   337         {
   358         {
   338             addSubject();
   359             addSubject();
       
   360             setFocus(mSubjectField);
   339         }
   361         }
   340         break;
   362         break;
   341         case MsgBaseView::ADD_VCARD:
   363         case MsgBaseView::ADD_VCARD:
   342         {
   364         {
   343             contactsFetched(editorData.at(2));
   365             contactsFetched(editorData.at(2));
   353     }
   375     }
   354 
   376 
   355     // additional common operations for non-forwarded messages
   377     // additional common operations for non-forwarded messages
   356     if(editorOp != MsgBaseView::FORWARD_MSG)
   378     if(editorOp != MsgBaseView::FORWARD_MSG)
   357     {
   379     {
   358         mToField->setAddresses(messageDetails->toAddressList());
   380         if(editorOp == MsgBaseView::ADD_RECIPIENTS)
       
   381         {
       
   382             // CV sends contact card address as the first address
       
   383             ConvergedMessageAddressList toAddresses = 
       
   384                     messageDetails->toAddressList();
       
   385             int addrCount = toAddresses.count();
       
   386             if(addrCount > 0)
       
   387             {
       
   388                 // add contact card address first
       
   389                 ConvergedMessageAddress *firstAddress =
       
   390                         new ConvergedMessageAddress();
       
   391                 firstAddress->setAlias(toAddresses.at(0)->alias());
       
   392                 firstAddress->setAddress(toAddresses.at(0)->address());
       
   393                 ConvergedMessageAddressList firstList;
       
   394                 firstList << firstAddress;
       
   395                 mToField->setAddresses(firstList);
       
   396             
       
   397                 // add remaining contacts now
       
   398                 ConvergedMessageAddressList otherList;
       
   399                 for(int i=1; i<addrCount; i++)
       
   400                 {
       
   401                     otherList << toAddresses.at(i);
       
   402                 }
       
   403                 mToField->setAddresses(otherList);
       
   404             }
       
   405         }
       
   406         else
       
   407         {
       
   408             mToField->setAddresses(messageDetails->toAddressList());
       
   409         }
   359         QString bodyTxt = messageDetails->bodyText();
   410         QString bodyTxt = messageDetails->bodyText();
   360         mBody->setText(bodyTxt);
   411         mBody->setText(bodyTxt);
   361 
   412 
   362         int attachmentCount = messageDetails->attachments().count();
   413         int attachmentCount = messageDetails->attachments().count();
   363         QStringList pendingAttList;
   414         QStringList pendingAttList;
   374             switch(mediaType)
   425             switch(mediaType)
   375             {
   426             {
   376                 case EMsgMediaImage:
   427                 case EMsgMediaImage:
   377                 {
   428                 {
   378                     mBody->setImage(filePath);
   429                     mBody->setImage(filePath);
   379                     addSubject();
       
   380                 }
   430                 }
   381                 break;
   431                 break;
   382                 case EMsgMediaVideo:
   432                  case EMsgMediaAudio:
   383                 {
       
   384                     mBody->setVideo(filePath);
       
   385                     addSubject();
       
   386                 }
       
   387                 break;
       
   388                 case EMsgMediaAudio:
       
   389                 {
   433                 {
   390                     mBody->setAudio(filePath);
   434                     mBody->setAudio(filePath);
   391                     addSubject();
       
   392                 }
   435                 }
   393                 break;
   436                 break;
   394                 default:
   437                 default:
   395                 {
   438                 {
   396                     pendingAttList << filePath;
   439                     pendingAttList << filePath;
   399             }
   442             }
   400         }
   443         }
   401         // add pending attachments in bulk
   444         // add pending attachments in bulk
   402         addAttachments(pendingAttList);
   445         addAttachments(pendingAttList);
   403     }
   446     }
   404     delete messageDetails;
   447     delete messageDetails; 
   405 }
   448 }
   406 
   449 
   407 void MsgUnifiedEditorView::populateContentIntoEditor(
   450 void MsgUnifiedEditorView::populateContentIntoEditor(
   408     const ConvergedMessage& messageDetails)
   451     const ConvergedMessage& messageDetails,bool draftMessage)
   409 {
   452 {
   410     // skip first-time MMS type switch note for draft
   453     // skip first-time MMS type switch note for draft
   411     mMsgMonitor->setSkipNote(true);
   454     mMsgMonitor->setSkipNote(true);
       
   455     mToField->skipMaxRecipientQuery(true);
       
   456 
   412     mToField->setAddresses(messageDetails.toAddressList());
   457     mToField->setAddresses(messageDetails.toAddressList());
   413     if(messageDetails.ccAddressList().count() > 0 )
   458     if(messageDetails.ccAddressList().count() > 0 )
   414     {
   459     {
   415         if(!mCcField)
   460         if(!mCcField)
   416         {
   461         {
   470 
   515 
   471             switch(mediaType)
   516             switch(mediaType)
   472             {
   517             {
   473                 case EMsgMediaImage:
   518                 case EMsgMediaImage:
   474                 {
   519                 {
   475                     mBody->setImage(filePath);
   520                     mBody->setImage(filePath,draftMessage);
   476                     addSubject();
       
   477                     break;
       
   478                 }
       
   479                 case EMsgMediaVideo:
       
   480                 {
       
   481                     mBody->setVideo(filePath);
       
   482                     addSubject();
       
   483                     break;
   521                     break;
   484                 }
   522                 }
   485                 case EMsgMediaAudio:
   523                 case EMsgMediaAudio:
   486                 {
   524                 {
   487                     mBody->setAudio(filePath);
   525                     mBody->setAudio(filePath);
   488                     addSubject();
       
   489                     break;
   526                     break;
   490                 }
   527                 }
   491                 default:
   528                 default:
   492                 {
   529                 {
   493                     pendingAttList << filePath;
   530                     pendingAttList << filePath;
   503     // add pending attachments to editor
   540     // add pending attachments to editor
   504     addAttachments(pendingAttList);
   541     addAttachments(pendingAttList);
   505 
   542 
   506     delete genUtils;
   543     delete genUtils;
   507     // ensure that any msg-type change after this are shown
   544     // ensure that any msg-type change after this are shown
       
   545     mToField->skipMaxRecipientQuery(false);
   508     mMsgMonitor->setSkipNote(false);
   546     mMsgMonitor->setSkipNote(false);
   509 }
   547 }
   510 
   548 
   511 void MsgUnifiedEditorView::addToolBar()
   549 void MsgUnifiedEditorView::addToolBar()
   512 {
   550 {
   517     //tool bar extension for attach action.
   555     //tool bar extension for attach action.
   518     HbToolBarExtension* attachExtension = new HbToolBarExtension();
   556     HbToolBarExtension* attachExtension = new HbToolBarExtension();
   519     HbAction *attachAction = toolBar->addExtension(attachExtension);    
   557     HbAction *attachAction = toolBar->addExtension(attachExtension);    
   520     attachAction->setIcon(HbIcon(ATTACH_ICON));
   558     attachAction->setIcon(HbIcon(ATTACH_ICON));
   521     
   559     
   522     HbListWidget* extnList = new HbListWidget();
   560     mTBExtnContentWidget = new HbListWidget();
   523     extnList->addItem(LOC_PHOTO);
   561     mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
   524     extnList->addItem(LOC_SOUND);
   562     mTBExtnContentWidget->addItem(LOC_PHOTO);
   525     extnList->addItem(LOC_BUSINESS_CARD);
   563     mTBExtnContentWidget->addItem(LOC_SOUND);
   526 
   564     mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
   527     HbListViewItem *prototype = extnList->listItemPrototype();
   565 
       
   566     HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype();
   528     HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces);
   567     HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces);
   529     prototype->setDefaultFrame(frame);
   568     prototype->setDefaultFrame(frame);
   530 
   569 
   531     connect(extnList, SIGNAL(activated(HbListWidgetItem*)), this,
   570     connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
   532             SLOT(handleViewExtnActivated(HbListWidgetItem*)));
   571             this, SLOT(handleViewExtnActivated(HbListWidgetItem*)));
   533     connect(extnList, SIGNAL(activated(HbListWidgetItem*)), attachExtension, SLOT(close()));
   572     connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
   534 
   573             attachExtension, SLOT(close()));
   535     attachExtension->setContentWidget(extnList);
   574 
       
   575     attachExtension->setContentWidget(mTBExtnContentWidget);
   536 
   576 
   537     //Add Action to the toolbar and show toolbar
   577     //Add Action to the toolbar and show toolbar
   538     toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
   578     mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
   539 
   579     mSendAction->setDisabled(true);
   540 
   580 
   541     setToolBar(toolBar);
   581     setToolBar(toolBar);
   542 }
   582 }
   543 
   583 
   544 void MsgUnifiedEditorView::addSubject()
   584 void MsgUnifiedEditorView::addSubject()
   545 {
   585 {
   546     if(mSubjectField)
   586     if(mSubjectField)
   547     { // do nothing if already present
   587     { // do nothing if already present
   548         return;
   588         return;
   549     }
   589     }
   550     // remove mainmenu's "Add Subject" action
       
   551     HbMenu* mainMenu = this->menu();
       
   552     mainMenu->removeAction(mSubjectAction);
       
   553     mSubjectAction->setParent(NULL);
       
   554     delete mSubjectAction;
       
   555 
   590 
   556     int index =0;
   591     int index =0;
   557     int offset = 1;
   592     int offset = 1;
   558     if(mAttachmentContainer)
   593     if(mAttachmentContainer)
   559     {
   594     {
   560         ++offset;
   595         ++offset;
   561     }
   596     }
   562     index = mMainLayout->count() - offset;
   597     index = mMainLayout->count() - offset;
   563 
   598 
   564     mSubjectField = new MsgUnifiedEditorSubject(mPluginPath, mContentWidget);
   599     mSubjectField = new MsgUnifiedEditorSubject( mContentWidget);
       
   600     
   565     mMainLayout->insertItem(index,mSubjectField);
   601     mMainLayout->insertItem(index,mSubjectField);
   566     connect(mSubjectField, SIGNAL(contentChanged()),
   602     connect(mSubjectField, SIGNAL(contentChanged()),
   567             mMsgMonitor, SLOT(checkMsgTypeChange()));    
   603             mMsgMonitor, SLOT(handleContentChange()));
       
   604     connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
       
   605     
       
   606     //set focus to subject field.
       
   607     HbAction* subjectAction = qobject_cast<HbAction*>(this->sender());
       
   608     if(subjectAction)
       
   609     {
       
   610         setFocus(mSubjectField);
       
   611     }
       
   612     
       
   613     // remove mainmenu's "Add Subject" action
       
   614     if(mSubjectAction)
       
   615     {
       
   616         HbMenu* mainMenu = this->menu();
       
   617         mainMenu->removeAction(mSubjectAction);
       
   618         mSubjectAction->setParent(NULL);
       
   619         delete mSubjectAction;
       
   620     }
   568 }
   621 }
   569 
   622 
   570 void MsgUnifiedEditorView::addCcBcc()
   623 void MsgUnifiedEditorView::addCcBcc()
   571 {
   624 {
   572     if(mCcField && mBccField)
   625     if(mCcField && mBccField)
   573     { // do nothing if already present
   626     { // do nothing if already present
   574         return;
   627         return;
   575     }
   628     }
   576 
   629 
   577     // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
   630     mCcField    = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget );
   578     HbMenu* mainmenu = this->menu();
   631     mBccField   = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget );
   579     mainmenu->removeAction(mCcBccAction);
   632     mCcField->skipMaxRecipientQuery(true);
   580     mCcBccAction->setParent(NULL);
   633     mBccField->skipMaxRecipientQuery(true);
   581     delete mCcBccAction;
       
   582 
       
   583     mCcField    = new MsgUnifiedEditorAddress( LOC_CC, mPluginPath, mContentWidget );
       
   584     mBccField   = new MsgUnifiedEditorAddress( LOC_BCC, mPluginPath, mContentWidget );
       
   585 
   634 
   586     connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send()));
   635     connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send()));
   587     connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange()));
   636     connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
       
   637     connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
       
   638     
   588     connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send()));
   639     connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send()));
   589     connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange()));
   640     connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
       
   641     connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
   590 
   642 
   591     HbWidget* groupWidget = new HbWidget(mContentWidget);
   643     HbWidget* groupWidget = new HbWidget(mContentWidget);
   592     groupWidget->setContentsMargins(0,0,0,0);
   644     groupWidget->setContentsMargins(0,0,0,0);
   593     
   645     
   594     QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget);
   646     QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget);
   602 
   654 
   603     HbGroupBox* groupBox = new HbGroupBox(0);    
   655     HbGroupBox* groupBox = new HbGroupBox(0);    
   604     groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
   656     groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
   605     
   657     
   606     groupBox->setContentWidget(groupWidget);
   658     groupBox->setContentWidget(groupWidget);
   607     groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
   659     groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
   608     mMainLayout->insertItem(1,groupBox);
   660     mMainLayout->insertItem(1,groupBox);
   609     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
   661     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
   610     
   662     
   611     // add subject field too
   663     // add subject field too
   612     addSubject();
   664     addSubject();
       
   665 
       
   666     //set focus to Cc field.
       
   667     HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender());
       
   668     if(mCcBccAction)
       
   669     {
       
   670         setFocus(mCcField);
       
   671     }
       
   672     
       
   673     // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
       
   674     if(mCcBccAction)
       
   675     {
       
   676     HbMenu* mainmenu = this->menu();
       
   677     mainmenu->removeAction(mCcBccAction);
       
   678     mCcBccAction->setParent(NULL);
       
   679     delete mCcBccAction;
       
   680     }
   613     
   681     
   614     this->updateGeometry();
   682     this->updateGeometry();
   615 }
   683 }
   616 
   684 
   617 void MsgUnifiedEditorView::updateOtherRecipientCount(bool state)
   685 void MsgUnifiedEditorView::updateOtherRecipientCount(bool state)
   619     HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender());
   687     HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender());
   620     if(groupBox)
   688     if(groupBox)
   621     {
   689     {
   622         if(!state)
   690         if(!state)
   623         {
   691         {
   624            groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
   692            groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
   625         }
   693         }
   626         else
   694         else
   627         {
   695         {
   628             int addrCount = mCcField->addressCount();
   696             int addrCount = mCcField->addressCount();
   629             addrCount += mBccField->addressCount();
   697             addrCount += mBccField->addressCount();
   630             groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));
   698             if(addrCount > 0)
       
   699             {
       
   700                 groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));    
       
   701             }
   631         }
   702         }
   632     }
   703     }
   633 }
   704 }
   634 
   705 
   635 void MsgUnifiedEditorView::changePriority()
   706 void MsgUnifiedEditorView::changePriority()
   645 
   716 
   646     addSubject();
   717     addSubject();
   647     mSubjectField->setPriority(priority);
   718     mSubjectField->setPriority(priority);
   648 }
   719 }
   649 
   720 
   650 void MsgUnifiedEditorView::sendingOptions()
       
   651 {
       
   652 }
       
   653 
       
   654 void MsgUnifiedEditorView::deleteMessage()
   721 void MsgUnifiedEditorView::deleteMessage()
   655 {
   722 {
   656     bool ok = HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,
   723     HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,
   657                                             LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
   724                            SLOT(onDialogDeleteMsg(HbAction*)),
   658     
   725                            HbMessageBox::Delete | HbMessageBox::Cancel);
   659     if(ok)
       
   660         {
       
   661         mCanSaveToDrafts = false;
       
   662     
       
   663         //delete if draft entry opened
       
   664         if( mOpenedMessageId.getId() != -1)
       
   665             {    
       
   666             if(!mPluginLoader)
       
   667                 {
       
   668                 mPluginLoader = new UniEditorPluginLoader(this);
       
   669                 }
       
   670         
       
   671             UniEditorPluginInterface* pluginInterface =
       
   672                 mPluginLoader->getUniEditorPlugin(MsgMonitor::messageType());
       
   673         
       
   674             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
       
   675             }
       
   676     
       
   677         //trigger back action.
       
   678         HbAction* backAction = this->navigationAction();
       
   679         if(backAction)
       
   680             {
       
   681             backAction->trigger();
       
   682             }
       
   683         }
       
   684 }
   726 }
   685 
   727 
   686 void MsgUnifiedEditorView::removeAttachmentContainer()
   728 void MsgUnifiedEditorView::removeAttachmentContainer()
   687 {
   729 {
   688     if(mAttachmentContainer)
   730     if(mAttachmentContainer)
   698 {    
   740 {    
   699     int fcount = files.count();
   741     int fcount = files.count();
   700     int i=0;
   742     int i=0;
   701     for(i=0; i<fcount; i++)
   743     for(i=0; i<fcount; i++)
   702     {
   744     {
   703         if(MsgAttachmentContainer::EAddSizeExceed 
   745         int status = addAttachment(files.at(i));
   704                 == addAttachment(files.at(i)))
   746         if(status == MsgAttachmentContainer::EAddSizeExceed)
   705         {
   747         {
   706             // size already exceeds max mms size-limit
   748             QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS)
       
   749                     .arg(fcount-i).arg(fcount);
       
   750             HbNotificationDialog::launchDialog(displayStr);
   707             break;
   751             break;
   708         }
   752         }
   709     }
   753     }
   710     // check if some files failed to add
       
   711     // happens only when size exceeded during addition
       
   712     if(i<fcount)
       
   713     {
       
   714         // TODO: show a note for size exceed
       
   715     }
       
   716 }
   754 }
   717 
   755 
   718 int MsgUnifiedEditorView::addAttachment(const QString& filepath)
   756 int MsgUnifiedEditorView::addAttachment(const QString& filepath)
   719 {
   757 {
       
   758     // do nothing if filepath is empty
       
   759     if(filepath.isEmpty())
       
   760     {
       
   761         return MsgAttachmentContainer::EAddSuccess;
       
   762     }
       
   763 
   720     if(!mAttachmentContainer)
   764     if(!mAttachmentContainer)
   721     {
   765     {
   722         mAttachmentContainer = new MsgAttachmentContainer(mPluginPath, mContentWidget);
   766         mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
   723         connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()),
   767         connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()),
   724                 this, SLOT(removeAttachmentContainer()));
   768                 this, SLOT(removeAttachmentContainer()));
   725         connect(mAttachmentContainer, SIGNAL(contentChanged()),
   769         connect(mAttachmentContainer, SIGNAL(contentChanged()),
   726                 mMsgMonitor, SLOT(checkMsgTypeChange()));
   770                 mMsgMonitor, SLOT(handleContentChange()));
       
   771         connect(mAttachmentContainer, SIGNAL(contentChanged()),
       
   772                 this,SLOT(onContentChanged()));
       
   773         
   727         int index = mMainLayout->count() - 1;
   774         int index = mMainLayout->count() - 1;
   728         mMainLayout->insertItem(index,mAttachmentContainer);
   775         mMainLayout->insertItem(index,mAttachmentContainer);
   729     }
   776     }
   730 
   777 
   731     int ret = mAttachmentContainer->addAttachment(filepath);
   778     int ret = mAttachmentContainer->addAttachment(filepath);
   735         if(mAttachmentContainer->count() == 0)
   782         if(mAttachmentContainer->count() == 0)
   736         {
   783         {
   737             removeAttachmentContainer();
   784             removeAttachmentContainer();
   738         }
   785         }
   739     }
   786     }
   740     else if(mAttachmentContainer->hasMMContent())
       
   741     {
       
   742         // when msg is converted to MMS, subject needs to be auto-inserted
       
   743         addSubject();
       
   744     }
       
   745     return ret;
   787     return ret;
   746 }
   788 }
   747 
   789 
   748 QString MsgUnifiedEditorView::pluginPath()
       
   749 {
       
   750     QString pluginPath;
       
   751     #ifdef Q_OS_WIN
       
   752     #define PLUGINPATH "../unifiededitorplugin/debug/unifiededitorplugind.dll"
       
   753     #endif
       
   754     #ifdef Q_OS_SYMBIAN
       
   755     #define PLUGINPATH "unifiededitorplugin.dll"
       
   756     #endif
       
   757     pluginPath.append(PLUGINPATH);
       
   758     return pluginPath;
       
   759 }
       
   760 
       
   761 void MsgUnifiedEditorView::send()
   790 void MsgUnifiedEditorView::send()
   762 {
   791 {
   763     activateInputBlocker();
   792     activateInputBlocker();
       
   793     
       
   794     // first run the address validation tests
       
   795     if( !mToField->validateContacts() ||
       
   796         (mCcField && !mCcField->validateContacts()) ||
       
   797         (mBccField && !mBccField->validateContacts()) )
       
   798     {
       
   799         deactivateInputBlocker();
       
   800         return;
       
   801     }
   764 
   802 
   765     // converged msg for sending
   803     // converged msg for sending
   766     ConvergedMessage msg;
   804     ConvergedMessage msg;
   767     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
   805     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
   768     msg.setMessageType(messageType);
   806     msg.setMessageType(messageType);
   769 
   807 
   770     ConvergedMessageAddressList addresses = mToField->addresses();
   808     // we need to remove duplicate addresses
       
   809     bool removeDuplicates = true;
       
   810     ConvergedMessageAddressList addresses =
       
   811             mToField->addresses(removeDuplicates);
   771     if(messageType == ConvergedMessage::Sms &&
   812     if(messageType == ConvergedMessage::Sms &&
   772        addresses.isEmpty())
   813        addresses.isEmpty())
   773     {
   814     {
   774         // no recipient specified for sms, do not send msg
   815         // no recipient specified for sms, do not send msg
   775         deactivateInputBlocker();
   816         deactivateInputBlocker();
   778 
   819 
   779     ConvergedMessageAddressList ccAddresses;
   820     ConvergedMessageAddressList ccAddresses;
   780     ConvergedMessageAddressList bccAddresses;
   821     ConvergedMessageAddressList bccAddresses;
   781     if(mCcField)
   822     if(mCcField)
   782     {
   823     {
   783         ccAddresses = mCcField->addresses();
   824         ccAddresses = mCcField->addresses(removeDuplicates);
   784     }
   825     }
   785     if(mBccField)
   826     if(mBccField)
   786     {
   827     {
   787         bccAddresses = mBccField->addresses();
   828         bccAddresses = mBccField->addresses(removeDuplicates);
   788     }
   829     }
   789     if( messageType == ConvergedMessage::Mms &&
   830     if( messageType == ConvergedMessage::Mms &&
   790             addresses.isEmpty() &&
   831             addresses.isEmpty() &&
   791             ccAddresses.isEmpty() &&
   832             ccAddresses.isEmpty() &&
   792             bccAddresses.isEmpty())
   833             bccAddresses.isEmpty())
   793     {
   834     {
   794         // no recipient specified for mms, do not send msg
   835         // no recipient specified for mms, do not send msg
   795         deactivateInputBlocker();
   836         deactivateInputBlocker();
   796         return;
   837         return;
   797     }
   838     }
       
   839     
       
   840     //close vkb before switching view.
       
   841     mVkbHost->closeKeypad(true);
   798 
   842 
   799     packMessage(msg);
   843     packMessage(msg);
   800     
   844     
   801     // send message
   845     // send message
   802     MsgSendUtil *sendUtil = new MsgSendUtil(this);
   846     MsgSendUtil *sendUtil = new MsgSendUtil(this);
   847             if(bccCount)
   891             if(bccCount)
   848             {
   892             {
   849                 receipient = addrList.at(0)->address();
   893                 receipient = addrList.at(0)->address();
   850             }
   894             }
   851         }
   895         }
   852 
   896         
   853 
       
   854     QVariantList params;
   897     QVariantList params;
   855 
   898 
   856     if(recepientCount == 1 )
   899     if(recepientCount == 1 )
   857         {
   900         {
   858         params << MsgBaseView::CV;  // target view
   901         params << MsgBaseView::CV;  // target view
   871     else
   914     else
   872     {
   915     {
   873         deactivateInputBlocker();
   916         deactivateInputBlocker();
   874         if(sendResult == KErrNotFound)
   917         if(sendResult == KErrNotFound)
   875         {
   918         {
   876         	  bool result = HbMessageBox::question("Settings not defined\nDefine now ?",
   919             if (messageType == ConvergedMessage::Sms)
   877                                          LOC_DIALOG_OK,
       
   878                                          LOC_BUTTON_CANCEL);
       
   879             if (result)
       
   880             {
   920             {
   881               QVariantList params;
   921                 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
   882               params << MsgBaseView::MSGSETTINGS;// target view
   922                                        this,SLOT(onDialogSmsSettings(HbAction*)),
   883               params << MsgBaseView::UNIEDITOR; // source view
   923                                        HbMessageBox::Ok | HbMessageBox::Cancel);
   884               emit switchView(params);
   924             }
   885             }
   925             else
   886         }
   926             {
   887     }
   927                 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
   888 }
   928                                        this,SLOT(onDialogMmsSettings(HbAction*)),                             
   889 
   929                                        HbMessageBox::Ok | HbMessageBox::Cancel);
   890 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg)
   930             }
   891 {
   931         }
   892     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
   932     }
       
   933 }
       
   934 
       
   935 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
       
   936 {
       
   937     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
   893     msg.setMessageType(messageType);
   938     msg.setMessageType(messageType);
   894 
   939     // If isSave is true (save to draft usecase), then don't remove duplicates
   895     ConvergedMessageAddressList addresses = mToField->addresses();
   940     // If isSave is false (send usecase), then remove duplicates
       
   941     bool removeDuplicates = !isSave;
       
   942     ConvergedMessageAddressList addresses = 
       
   943             mToField->addresses(removeDuplicates);
   896     ConvergedMessageAddressList ccAddresses;
   944     ConvergedMessageAddressList ccAddresses;
   897     ConvergedMessageAddressList bccAddresses;
   945     ConvergedMessageAddressList bccAddresses;
   898 
   946 
   899     msg.addToRecipients(addresses);
   947     msg.addToRecipients(addresses);
   900     msg.setBodyText(mBody->text());
   948     msg.setBodyText(mBody->text());
   904 
   952 
   905     if(messageType == ConvergedMessage::Mms)
   953     if(messageType == ConvergedMessage::Mms)
   906     {
   954     {
   907         if(mCcField)
   955         if(mCcField)
   908         {
   956         {
   909             ccAddresses = mCcField->addresses();
   957             ccAddresses = mCcField->addresses(removeDuplicates);
   910         }
   958         }
   911 
   959 
   912         if(mBccField)
   960         if(mBccField)
   913         {
   961         {
   914             bccAddresses = mBccField->addresses();
   962             bccAddresses = mBccField->addresses(removeDuplicates);
   915         }
   963         }
   916 
   964 
   917         int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits();
   965         if(removeDuplicates)
   918         //comapre cc and to field,remove duplicate from cc
   966         {
   919         foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
   967             int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits();
   920         {
   968             //comapre cc and to field,remove duplicate from cc
   921           foreach(ConvergedMessageAddress *toAddress,addresses)
   969             foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
   922           {
   970             {
   923              if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
   971                 foreach(ConvergedMessageAddress *toAddress,addresses)
   924              {
   972                 {
   925                 ccAddresses.removeOne(ccAddress);
   973                     if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
   926              }
   974                     {
   927           }
   975                         ccAddresses.removeOne(ccAddress);
   928         }
   976                     }
   929         //comapre bcc and cc field,remove duplicate from bcc
   977                 }
   930         foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
   978             }
   931         {
   979             //comapre bcc and cc field,remove duplicate from bcc
   932           foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
   980             foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
   933           {
   981             {
   934              if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount)))
   982                 foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
   935              {
   983                 {
   936                 bccAddresses.removeOne(bccAddress);
   984                     if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount)))
   937              }
   985                     {
   938           }
   986                         bccAddresses.removeOne(bccAddress);
   939         }
   987                     }
   940         //comapre bcc and to field,remove duplicate from bcc
   988                 }
   941         foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
   989             }
   942         {
   990             //comapre bcc and to field,remove duplicate from bcc
   943           foreach(ConvergedMessageAddress *toAddress,addresses)
   991             foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
   944           {
   992             {
   945              if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
   993                 foreach(ConvergedMessageAddress *toAddress,addresses)
   946              {
   994                 {
   947                 bccAddresses.removeOne(bccAddress);
   995                     if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
   948              }
   996                     {
   949           }
   997                         bccAddresses.removeOne(bccAddress);
       
   998                     }
       
   999                 }
       
  1000             }
   950         }
  1001         }
   951 
  1002 
   952         if(ccAddresses.count()>0)
  1003         if(ccAddresses.count()>0)
   953         {
  1004         {
   954         msg.addCcRecipients(ccAddresses);
  1005         msg.addCcRecipients(ccAddresses);
  1003         {
  1054         {
  1004             msg.addAttachments(attachmentList);
  1055             msg.addAttachments(attachmentList);
  1005         }
  1056         }
  1006 }
  1057 }
  1007 
  1058 
  1008 void MsgUnifiedEditorView::saveContentToDrafts()
  1059 int MsgUnifiedEditorView::saveContentToDrafts()
  1009 {
  1060 {
  1010     if(!mCanSaveToDrafts)
  1061     if(!mCanSaveToDrafts)
  1011         {
  1062         {
  1012         return;
  1063         return mOpenedMessageId.getId(); // return currently opened message id
  1013         }
  1064         }
       
  1065     
  1014     activateInputBlocker();
  1066     activateInputBlocker();
  1015     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
  1067     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
  1016 
  1068 
  1017     ConvergedMessageAddressList addresses = mToField->addresses();
  1069     ConvergedMessageAddressList addresses = mToField->addresses();
  1018 
  1070 
  1019     UniEditorPluginInterface* pluginInterface = NULL;
  1071     UniEditorPluginInterface* pluginInterface = NULL;
  1020 
  1072 
  1029             mPluginLoader->getUniEditorPlugin(messageType);
  1081             mPluginLoader->getUniEditorPlugin(messageType);
  1030     }
  1082     }
  1031 
  1083 
  1032     if(messageType == ConvergedMessage::Sms &&
  1084     if(messageType == ConvergedMessage::Sms &&
  1033             addresses.isEmpty() &&
  1085             addresses.isEmpty() &&
  1034             MsgMonitor::bodySize() <= 0 &&
  1086             MsgUnifiedEditorMonitor::bodySize() <= 0 &&
  1035             MsgMonitor::containerSize() <= 0)
  1087             MsgUnifiedEditorMonitor::containerSize() <= 0)
  1036     {
  1088     {
  1037         if(mOpenedMessageId.getId() != -1)
  1089         if(mOpenedMessageId.getId() != -1)
  1038         {
  1090         {
  1039         pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1091         pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1040         }
  1092         }
  1041 
  1093 
  1042         // if empty msg, do not save
  1094         // if empty msg, do not save
  1043         deactivateInputBlocker();
  1095         deactivateInputBlocker();
  1044         return;
  1096         return INVALID_MSGID;
  1045     }
  1097     }
  1046 
  1098 
  1047     ConvergedMessageAddressList ccAddresses;
  1099     ConvergedMessageAddressList ccAddresses;
  1048     ConvergedMessageAddressList bccAddresses;
  1100     ConvergedMessageAddressList bccAddresses;
  1049     if(mCcField)
  1101     if(mCcField)
  1063     if( messageType == ConvergedMessage::Mms &&
  1115     if( messageType == ConvergedMessage::Mms &&
  1064             addresses.isEmpty() &&
  1116             addresses.isEmpty() &&
  1065             ccAddresses.isEmpty() &&
  1117             ccAddresses.isEmpty() &&
  1066             bccAddresses.isEmpty() &&
  1118             bccAddresses.isEmpty() &&
  1067             subectSize <= 0 &&
  1119             subectSize <= 0 &&
  1068             MsgMonitor::bodySize() <= 0 &&
  1120             MsgUnifiedEditorMonitor::bodySize() <= 0 &&
  1069             MsgMonitor::containerSize() <= 0)
  1121             MsgUnifiedEditorMonitor::containerSize() <= 0)
  1070     {
  1122     {
  1071         if(mOpenedMessageId.getId() != -1)
  1123         if(mOpenedMessageId.getId() != -1)
  1072         {
  1124         {
  1073             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1125             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1074         }
  1126         }
  1075         // if empty msg, do not send
  1127         // if empty msg, do not send
  1076         deactivateInputBlocker();
  1128         deactivateInputBlocker();
  1077         return;
  1129         return INVALID_MSGID;
  1078     }
  1130     }
  1079     ConvergedMessage msg;
  1131     ConvergedMessage msg;
  1080     packMessage(msg);
  1132     packMessage(msg, true);
  1081 
  1133 
  1082     // save to drafts
  1134     // save to drafts
  1083     MsgSendUtil *sendUtil = new MsgSendUtil(this);
  1135     MsgSendUtil *sendUtil = new MsgSendUtil(this);
  1084     int msgId = sendUtil->saveToDrafts(msg);
  1136     int msgId = sendUtil->saveToDrafts(msg);
  1085     delete sendUtil;
  1137     delete sendUtil;
  1098     
  1150     
  1099     if(res)
  1151     if(res)
  1100         {
  1152         {
  1101         HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
  1153         HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
  1102         }
  1154         }
       
  1155     return msgId;
  1103 }
  1156 }
  1104 
  1157 
  1105 void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
  1158 void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
  1106 {
  1159 {
  1107  Q_UNUSED(event)
  1160  Q_UNUSED(event)
  1111 
  1164 
  1112  mContentWidget->resize(this->rect().width(),this->rect().height()+1);
  1165  mContentWidget->resize(this->rect().width(),this->rect().height()+1);
  1113 }
  1166 }
  1114 
  1167 
  1115 //---------------------------------------------------------------
  1168 //---------------------------------------------------------------
  1116 // editorTempPath
       
  1117 // @return fullPath of unified editor's temporary dir
       
  1118 //---------------------------------------------------------------
       
  1119 QString editorTempPath()
       
  1120 {
       
  1121     QDir tempDir = QDir(QString());
       
  1122     QString tempPath(QDir::toNativeSeparators(tempDir.tempPath()));
       
  1123     tempPath.append(QDir::separator());
       
  1124     tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER);
       
  1125     tempPath.append(QDir::separator());
       
  1126     return tempPath;
       
  1127 }
       
  1128 
       
  1129 //---------------------------------------------------------------
       
  1130 // MsgUnifiedEditorView::createVCards
  1169 // MsgUnifiedEditorView::createVCards
  1131 // @see header file
  1170 // @see header file
  1132 //---------------------------------------------------------------
  1171 //---------------------------------------------------------------
  1133 int MsgUnifiedEditorView::createVCards(
  1172 int MsgUnifiedEditorView::createVCards(
  1134         const QVariant& value, QStringList& filelist)
  1173         const QVariant& value, QStringList& filelist)
  1135 {
  1174 {
  1136     // make sure that temp-folder is created for storing vcards
  1175     // make sure that temp-folder is created for storing vcards
  1137     QDir tempDir = QDir(QString());
  1176     if(!createTempFolder())
  1138     if(!tempDir.mkpath(editorTempPath()))
       
  1139     {
  1177     {
  1140         return KErrGeneral;
  1178         return KErrGeneral;
  1141     }
  1179     }
  1142     tempDir.cd(editorTempPath());
       
  1143 
       
  1144 
  1180 
  1145     // extract contact-list
  1181     // extract contact-list
  1146     QContactManager* contactManager = new QContactManager("symbian");
  1182     QContactManager* contactManager = new QContactManager("symbian");
  1147     CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value);
  1183     CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value);
  1148     int cntCount = cntServicesContacts.count();
  1184     int cntCount = cntServicesContacts.count();
  1214 // @algo For multiselected 'Unnamed' contacts, the filename should
  1250 // @algo For multiselected 'Unnamed' contacts, the filename should
  1215 // be synthesized as unnamed.vcf, unnamed1.vcf, unnamed2.vcf etc.
  1251 // be synthesized as unnamed.vcf, unnamed1.vcf, unnamed2.vcf etc.
  1216 //---------------------------------------------------------------
  1252 //---------------------------------------------------------------
  1217 QString MsgUnifiedEditorView::generateFileName(QString& suggestedName)
  1253 QString MsgUnifiedEditorView::generateFileName(QString& suggestedName)
  1218 {
  1254 {
  1219     QDir editorTempDir = QDir(QString());
  1255     QDir editorTempDir;
  1220     editorTempDir.cd(editorTempPath());
  1256     editorTempDir.cd(editorTempPath());
  1221 
  1257 
  1222     for(int i=0; i<MAX_VCARDS; i++)
  1258     for(int i=0; i<MAX_VCARDS; i++)
  1223     {
  1259     {
  1224         QString searchFileName = suggestedName;
  1260         QString searchFileName = suggestedName;
  1267     
  1303     
  1268     if(itemText == LOC_PHOTO)
  1304     if(itemText == LOC_PHOTO)
  1269         {
  1305         {
  1270         //launch photo picker.
  1306         //launch photo picker.
  1271         fetchImages();  
  1307         fetchImages();  
  1272     }
  1308         }
  1273     else if(itemText == LOC_SOUND)
  1309     else if(itemText == LOC_SOUND)
  1274         {
  1310         {
  1275         //launch audio picker
  1311         //launch audio picker
  1276         fetchAudio();
  1312         fetchAudio();
  1277     }
  1313         }
  1278     else if(itemText == LOC_BUSINESS_CARD)
  1314     else if(itemText == LOC_BUSINESS_CARD)
  1279         {
  1315         {
  1280         //launch contact card picker.
  1316         //launch contact card picker.
  1281         fetchContacts();
  1317         fetchContacts();
  1282     }
  1318         }
  1283    
  1319    
  1284 }
  1320 }
  1285 
  1321 
  1286 //---------------------------------------------------------------
  1322 //---------------------------------------------------------------
  1287 // MsgUnifiedEditorView::fetchContacts
  1323 // MsgUnifiedEditorView::fetchContacts
  1323 // MsgUnifiedEditorView::fetchImages
  1359 // MsgUnifiedEditorView::fetchImages
  1324 // @see header file
  1360 // @see header file
  1325 //---------------------------------------------------------------
  1361 //---------------------------------------------------------------
  1326 void MsgUnifiedEditorView::fetchImages()
  1362 void MsgUnifiedEditorView::fetchImages()
  1327 {
  1363 {
  1328     QString interface("Image");
  1364     QString service("photos");
  1329     QString operation("fetch(QVariantMap,QVariant)");
  1365     QString interface("com.nokia.symbian.IImageFetch");
       
  1366     QString operation("fetch()");
  1330     XQAiwRequest* request = NULL;
  1367     XQAiwRequest* request = NULL;
  1331     XQApplicationManager appManager;
  1368     XQApplicationManager appManager;
  1332     request = appManager.create(interface, operation, true);//embedded
  1369     request = appManager.create(service,interface, operation, true);//embedded
       
  1370     request->setSynchronous(true); // synchronous
  1333     if(!request)
  1371     if(!request)
  1334     {     
  1372     {     
  1335         QCRITICAL_WRITE("AIW-ERROR: NULL request");
  1373         QCRITICAL_WRITE("AIW-ERROR: NULL request");
  1336         return;
  1374         return;
  1337     }
  1375     }
  1338 
  1376 
  1339     connect(request, SIGNAL(requestOk(const QVariant&)),
  1377     connect(request, SIGNAL(requestOk(const QVariant&)),
  1340         this, SLOT(imagesFetched(const QVariant&)));
  1378         this, SLOT(imagesFetched(const QVariant&)));
  1341     connect(request, SIGNAL(requestError(int,const QString&)),
  1379     connect(request, SIGNAL(requestError(int,const QString&)),
  1342         this, SLOT(serviceRequestError(int,const QString&)));
  1380         this, SLOT(serviceRequestError(int,const QString&)));
  1343    
  1381     
  1344     // Make the request
  1382     // Make the request
  1345     if (!request->send())
  1383     if (!request->send())
  1346     {
  1384     {
  1347         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
  1385         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
  1348     }  
  1386     }  
  1353 // MsgUnifiedEditorView::fetchAudio
  1391 // MsgUnifiedEditorView::fetchAudio
  1354 // @see header file
  1392 // @see header file
  1355 //---------------------------------------------------------------
  1393 //---------------------------------------------------------------
  1356 void MsgUnifiedEditorView::fetchAudio()
  1394 void MsgUnifiedEditorView::fetchAudio()
  1357 {
  1395 {
  1358     QString service("Music Fetcher");
  1396     // Launch Audio fetcher view
  1359     QString interface("com.nokia.services.media.Music");
  1397     QVariantList params;
  1360     QString operation("fetch(QString)");
  1398     params << MsgBaseView::AUDIOFETCHER; // target view
  1361     XQAiwRequest* request = NULL;
  1399     params << MsgBaseView::UNIEDITOR; // source view
  1362     XQApplicationManager appManager;
  1400     emit switchView(params);
  1363     request = appManager.create(service, interface, operation, true); //embedded
       
  1364     if(!request)
       
  1365     {
       
  1366         QCRITICAL_WRITE("AIW-ERROR: NULL request");
       
  1367         return;
       
  1368     }
       
  1369 
       
  1370     connect(request, SIGNAL(requestOk(const QVariant&)),
       
  1371         this, SLOT(audiosFetched(const QVariant&)));
       
  1372     connect(request, SIGNAL(requestError(int,const QString&)),
       
  1373         this, SLOT(serviceRequestError(int,const QString&)));
       
  1374 
       
  1375     // Make the request
       
  1376     if (!request->send())
       
  1377     {
       
  1378         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed :",request->lastError());
       
  1379     }
       
  1380     delete request;
       
  1381 }
  1401 }
  1382 
  1402 
  1383 //---------------------------------------------------------------
  1403 //---------------------------------------------------------------
  1384 // MsgUnifiedEditorView::contactsFetched
  1404 // MsgUnifiedEditorView::contactsFetched
  1385 // @see header file
  1405 // @see header file
  1405         QStringList fileList = result.value<QStringList>();
  1425         QStringList fileList = result.value<QStringList>();
  1406         if ( fileList.size()>0 )
  1426         if ( fileList.size()>0 )
  1407         {
  1427         {
  1408             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
  1428             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
  1409             mBody->setImage(filepath);
  1429             mBody->setImage(filepath);
  1410             addSubject();
       
  1411         }
       
  1412     }
       
  1413 }
       
  1414 
       
  1415 //---------------------------------------------------------------
       
  1416 // MsgUnifiedEditorView::audiosFetched
       
  1417 // @see header file
       
  1418 //---------------------------------------------------------------
       
  1419 void MsgUnifiedEditorView::audiosFetched(const QVariant& result )
       
  1420 {
       
  1421     if(result.canConvert<QStringList>())
       
  1422     {
       
  1423         QStringList fileList = result.value<QStringList>();
       
  1424         if ( fileList.size()>0 && !fileList.at(0).isEmpty())
       
  1425         {
       
  1426             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
       
  1427             QDEBUG_WRITE_FORMAT("Received audio file path = ", fileList.at(0));
       
  1428             mBody->setAudio(filepath);
       
  1429             addSubject();
       
  1430         }
  1430         }
  1431     }
  1431     }
  1432 }
  1432 }
  1433 
  1433 
  1434 //---------------------------------------------------------------
  1434 //---------------------------------------------------------------
  1443 //---------------------------------------------------------------
  1443 //---------------------------------------------------------------
  1444 // MsgUnifiedEditorView::activateInputBlocker
  1444 // MsgUnifiedEditorView::activateInputBlocker
  1445 // @see header file
  1445 // @see header file
  1446 //--------------------------------------------------------------
  1446 //--------------------------------------------------------------
  1447 void MsgUnifiedEditorView::activateInputBlocker()
  1447 void MsgUnifiedEditorView::activateInputBlocker()
  1448     {
  1448 {
  1449         this->grabMouse();
  1449     mainWindow()->setInteractive(false);
  1450         this->grabKeyboard();
  1450 }
  1451     }
       
  1452 
  1451 
  1453 //---------------------------------------------------------------
  1452 //---------------------------------------------------------------
  1454 // MsgUnifiedEditorView::deactivateInputBlocker
  1453 // MsgUnifiedEditorView::deactivateInputBlocker
  1455 // @see header file
  1454 // @see header file
  1456 //--------------------------------------------------------------
  1455 //--------------------------------------------------------------
  1457 void MsgUnifiedEditorView::deactivateInputBlocker()
  1456 void MsgUnifiedEditorView::deactivateInputBlocker()
  1458     {    
  1457 {
  1459         this->ungrabKeyboard();
  1458     mainWindow()->setInteractive(true);
  1460         this->ungrabMouse();
  1459 }
       
  1460 
       
  1461 //---------------------------------------------------------------
       
  1462 // MsgUnifiedEditorView::setAttachOptionEnabled
       
  1463 // @see header file
       
  1464 //--------------------------------------------------------------
       
  1465 void MsgUnifiedEditorView::setAttachOptionEnabled(
       
  1466         MsgUnifiedEditorView::TBE_AttachOption opt, bool enable)
       
  1467 {
       
  1468     HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt);
       
  1469     wgtItem->setEnabled(enable);
       
  1470 }
       
  1471 
       
  1472 //---------------------------------------------------------------
       
  1473 // MsgUnifiedEditorView::vkbOpened
       
  1474 // @see header file
       
  1475 //---------------------------------------------------------------
       
  1476 void MsgUnifiedEditorView::vkbOpened()
       
  1477 {
       
  1478     hideChrome(true); 
       
  1479     
       
  1480     disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
       
  1481 }
       
  1482       
       
  1483 //---------------------------------------------------------------
       
  1484 // MsgUnifiedEditorView::vkbClosed
       
  1485 // @see header file
       
  1486 //---------------------------------------------------------------
       
  1487 void MsgUnifiedEditorView::vkbClosed()
       
  1488 {
       
  1489     hideChrome(false);
       
  1490     
       
  1491     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
       
  1492 }
       
  1493 
       
  1494 //---------------------------------------------------------------
       
  1495 // MsgUnifiedEditorView::hideChrome
       
  1496 //
       
  1497 //---------------------------------------------------------------
       
  1498 void MsgUnifiedEditorView::hideChrome(bool hide)
       
  1499 {
       
  1500     if(hide)
       
  1501     {        
       
  1502         this->setContentFullScreen(true);
       
  1503         this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem);
       
  1504     }
       
  1505     else
       
  1506     {
       
  1507         this->setContentFullScreen(false);
       
  1508         this->showItems(Hb::StatusBarItem | Hb::TitleBarItem);
       
  1509     }
       
  1510 }
       
  1511 
       
  1512 //---------------------------------------------------------------
       
  1513 // MsgUnifiedEditorView::doDelayedConstruction
       
  1514 //
       
  1515 //---------------------------------------------------------------
       
  1516 void MsgUnifiedEditorView::doDelayedConstruction()
       
  1517 {
       
  1518     addMenu();
       
  1519     createTempFolder();
       
  1520     
       
  1521     //Create VKB instance and listen to VKB open and close signals.
       
  1522     mVkbHost = new HbAbstractVkbHost(this);
       
  1523     connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
       
  1524     connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
       
  1525     
       
  1526     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
       
  1527     
       
  1528 }
       
  1529 
       
  1530 //---------------------------------------------------------------
       
  1531 // MsgUnifiedEditorView::createTempFolder
       
  1532 //
       
  1533 //---------------------------------------------------------------
       
  1534 bool MsgUnifiedEditorView::createTempFolder()
       
  1535 {
       
  1536     // create editor's temp folder
       
  1537     QDir tempDir;
       
  1538     QString tempPath(editorTempPath());
       
  1539     bool result = tempDir.mkpath(tempPath);    
       
  1540     return result;
       
  1541 }
       
  1542 
       
  1543 //---------------------------------------------------------------
       
  1544 // MsgUnifiedEditorView::removeTempFolder
       
  1545 //
       
  1546 //---------------------------------------------------------------
       
  1547 void MsgUnifiedEditorView::removeTempFolder()
       
  1548 {
       
  1549     QDir tempDir;
       
  1550     QString tempPath(editorTempPath());
       
  1551     tempDir.cd(tempPath);
       
  1552     QStringList contentList(tempDir.entryList());
       
  1553     
       
  1554     int contentCount = contentList.count();
       
  1555     for(int i=0; i<contentCount; i++)
       
  1556     {
       
  1557         tempDir.remove(contentList.at(i));
       
  1558     }
       
  1559     
       
  1560     tempDir.cdUp();
       
  1561     tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER); 
       
  1562 }
       
  1563 
       
  1564 //---------------------------------------------------------------
       
  1565 // MsgUnifiedEditorView::setFocus
       
  1566 //
       
  1567 //---------------------------------------------------------------
       
  1568 void MsgUnifiedEditorView::setFocus(MsgUnifiedEditorBaseWidget* item)
       
  1569 {
       
  1570     if(item)
       
  1571     {
       
  1572         item->setFocus();  
       
  1573     }
       
  1574 }
       
  1575 
       
  1576 //---------------------------------------------------------------
       
  1577 // MsgUnifiedEditorView::onContentChanged
       
  1578 //
       
  1579 //---------------------------------------------------------------
       
  1580 void MsgUnifiedEditorView::onContentChanged()
       
  1581 {
       
  1582     mCanSaveToDrafts = true; 
       
  1583 }
       
  1584 
       
  1585 //---------------------------------------------------------------
       
  1586 // MsgUnifiedEditorView::onDialogDeleteMsg
       
  1587 //---------------------------------------------------------------
       
  1588 void MsgUnifiedEditorView::onDialogDeleteMsg(HbAction* action)
       
  1589 {
       
  1590     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
  1591     if (action == dlg->actions().at(0)) {
       
  1592 
       
  1593         mCanSaveToDrafts = false;
       
  1594 
       
  1595         //delete if draft entry opened
       
  1596         if (mOpenedMessageId.getId() != -1) {
       
  1597             if (!mPluginLoader) {
       
  1598                 mPluginLoader = new UniEditorPluginLoader(this);
       
  1599             }
       
  1600 
       
  1601             UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin(
       
  1602                 MsgUnifiedEditorMonitor::messageType());
       
  1603 
       
  1604             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
       
  1605         }
       
  1606 
       
  1607         //trigger back action.
       
  1608         HbAction* backAction = this->navigationAction();
       
  1609         if (backAction) {
       
  1610             backAction->trigger();
       
  1611         }
       
  1612 
       
  1613     }
       
  1614 }
       
  1615 
       
  1616 //---------------------------------------------------------------
       
  1617 // MsgUnifiedEditorView::onDialogSmsSettings
       
  1618 //---------------------------------------------------------------
       
  1619 void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action)
       
  1620 {
       
  1621     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
  1622     if (action == dlg->actions().at(0)) {
       
  1623         
       
  1624         QVariantList params;
       
  1625         params << MsgBaseView::MSGSETTINGS;// target view
       
  1626         params << MsgBaseView::UNIEDITOR; // source view
       
  1627         params << MsgSettingsView::SMSView;
       
  1628         emit switchView(params);
       
  1629     
       
  1630     }
       
  1631 }
       
  1632 
       
  1633 //---------------------------------------------------------------
       
  1634 // MsgUnifiedEditorView::onDialogMmsSettings
       
  1635 //---------------------------------------------------------------
       
  1636 void MsgUnifiedEditorView::onDialogMmsSettings(HbAction* action)
       
  1637 {
       
  1638     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
  1639     if (action == dlg->actions().at(0)) {
       
  1640         
       
  1641         QVariantList params;
       
  1642         params << MsgBaseView::MSGSETTINGS;// target view
       
  1643         params << MsgBaseView::UNIEDITOR; // source view
       
  1644         params << MsgSettingsView::MMSView;
       
  1645         emit switchView(params); 
       
  1646     }
       
  1647 }
       
  1648 
       
  1649 //---------------------------------------------------------------
       
  1650 // MsgUnifiedEditorView::enableSendButton
       
  1651 // @see header file
       
  1652 //--------------------------------------------------------------
       
  1653 void MsgUnifiedEditorView::enableSendButton(bool enable)
       
  1654     {
       
  1655     if(mSendAction)
       
  1656         {
       
  1657          // enable/disable based on only if its disabled/enabled.
       
  1658          // this check is to avoid unnecessary calls to mSendAction->setEnabled(enable);
       
  1659         if(mSendAction->isEnabled() != enable )
       
  1660             mSendAction->setEnabled(enable);
       
  1661         }
  1461     }
  1662     }
  1462 
  1663 
  1463 //EOF
  1664 //EOF