emailuis/nmailui/src/nmeditorview.cpp
author hgs
Fri, 03 Sep 2010 14:07:42 +0300
changeset 66 084b5b1f02a7
parent 62 a8c646b56683
child 68 83cc6bae1de8
permissions -rw-r--r--
201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: Message editor view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
#include "nmuiheaders.h"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
// Layout file and view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml";
56
hgs
parents: 51
diff changeset
    21
static const char *NMUI_EDITOR_VIEW = "editorview";
hgs
parents: 51
diff changeset
    22
hgs
parents: 51
diff changeset
    23
// extension list item frame.
hgs
parents: 51
diff changeset
    24
static const QString NmPopupListFrame = "qtg_fr_popup_list_normal";
47
hgs
parents: 44
diff changeset
    25
static const QString NmDelimiter("; ");
57
hgs
parents: 56
diff changeset
    26
static const QString NmPriorityLow("low");
hgs
parents: 56
diff changeset
    27
static const QString NmPriorityNormal("normal");
hgs
parents: 56
diff changeset
    28
static const QString NmPriorityHigh("high");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
	\class NmEditorView
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
	\brief Mail editor view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    Constructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
NmEditorView::NmEditorView(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    NmApplication &application,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    NmUiStartParam* startParam,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    NmUiEngine &uiEngine,
43
hgs
parents: 40
diff changeset
    42
    NmAttachmentManager &attaManager,
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
    QGraphicsItem *parent)
40
hgs
parents: 23
diff changeset
    44
    : NmBaseView(startParam, application, parent),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    45
      mApplication(application),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    46
      mUiEngine(uiEngine),
43
hgs
parents: 40
diff changeset
    47
      mAttaManager(attaManager),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    48
      mDocumentLoader(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    49
      mHeaderWidget(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    50
      mMessage(NULL),
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
    51
      mContent(NULL),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    52
      mAttachmentListContextMenu(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    53
      mMessageCreationOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    54
      mAddAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    55
      mRemoveAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    56
      mWaitDialog(NULL),
40
hgs
parents: 23
diff changeset
    57
      mQueryDialog(NULL),
hgs
parents: 23
diff changeset
    58
      mAttachmentPicker(NULL),
43
hgs
parents: 40
diff changeset
    59
      mCcBccFieldVisible(false),
56
hgs
parents: 51
diff changeset
    60
      mServiceSendingDialog(NULL),
57
hgs
parents: 56
diff changeset
    61
      mHiddenPriorityName(NmPriorityNormal)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
{
43
hgs
parents: 40
diff changeset
    63
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    64
    
66
hgs
parents: 62
diff changeset
    65
    mDocumentLoader	= new NmUiDocumentLoader( mApplication.mainWindow() );
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    // Set object name
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    setObjectName("NmEditorView");
44
hgs
parents: 43
diff changeset
    68
    // call the createToolBar on load view layout
hgs
parents: 43
diff changeset
    69
    createToolBar();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    // Load view layout
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    loadViewLayout();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
    Destructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
NmEditorView::~NmEditorView()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
{
43
hgs
parents: 40
diff changeset
    79
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    80
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    81
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    82
        mRemoveAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    83
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    84
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    85
        mAddAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    86
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    87
    if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    88
        mMessageCreationOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    89
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    delete mMessage;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    mWidgetList.clear();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    delete mDocumentLoader;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    delete mPrioritySubMenu;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    94
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    95
    if (mAttachmentListContextMenu) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    96
        mAttachmentListContextMenu->clearActions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    97
        delete mAttachmentListContextMenu;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    98
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    99
    delete mWaitDialog;
40
hgs
parents: 23
diff changeset
   100
    delete mQueryDialog;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   101
    delete mAttachmentPicker;    
43
hgs
parents: 40
diff changeset
   102
    mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
   103
    mAttaManager.cancelFetch();
44
hgs
parents: 43
diff changeset
   104
    
hgs
parents: 43
diff changeset
   105
    // make sure virtual keyboard is closed
hgs
parents: 43
diff changeset
   106
    QInputContext *ic = qApp->inputContext();
hgs
parents: 43
diff changeset
   107
    if (ic) {
hgs
parents: 43
diff changeset
   108
        QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
hgs
parents: 43
diff changeset
   109
        ic->filterEvent(closeEvent);
hgs
parents: 43
diff changeset
   110
        delete closeEvent;
hgs
parents: 43
diff changeset
   111
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    View layout loading from XML
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
void NmEditorView::loadViewLayout()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
{
43
hgs
parents: 40
diff changeset
   119
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   120
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    mPrioritySubMenu = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    // Use document loader to load the view
47
hgs
parents: 44
diff changeset
   124
    bool ok(false);
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   125
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   126
    setObjectName(QString(NMUI_EDITOR_VIEW));
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   127
    QObjectList objectList;
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   128
    objectList.append(this);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   129
    // Pass the view to documentloader. Document loader uses this view
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   130
    // when docml is parsed, instead of creating new view.
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   131
    // documentloader is created in constructor
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   132
    mDocumentLoader->setObjectTree(objectList);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   133
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   136
   if (ok) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   137
        mContent = new NmEditorContent(this, mDocumentLoader, 
47
hgs
parents: 44
diff changeset
   138
            mApplication.networkAccessManager(), mApplication);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   140
        mHeaderWidget = mContent->header();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
        // Set default color for user - entered text if editor is in re/reAll/fw mode
44
hgs
parents: 43
diff changeset
   143
        if (mStartParam) {
hgs
parents: 43
diff changeset
   144
            NmUiEditorStartMode mode = mStartParam->editorStartMode();
hgs
parents: 43
diff changeset
   145
            if (mode == NmUiEditorReply
hgs
parents: 43
diff changeset
   146
                || mode == NmUiEditorReplyAll 
hgs
parents: 43
diff changeset
   147
                || mode == NmUiEditorForward) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   148
                mContent->editor()->setCustomTextColor(true, Qt::blue);
44
hgs
parents: 43
diff changeset
   149
            }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   152
        // the rest of the view initialization is done in viewReady()
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   153
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    Reload view contents with new start parameters
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    Typically when view is already open and external view activation occurs
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    for this same view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
void NmEditorView::reloadViewContents(NmUiStartParam* startParam)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
{
43
hgs
parents: 40
diff changeset
   163
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   164
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    // Check start parameter validity.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    if (startParam&&startParam->viewId()==NmUiViewMessageEditor) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
        // Delete existing start parameter data
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
        delete mStartParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
        mStartParam=NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        // Store new start parameter data
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        mStartParam=startParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        // Store existing edited message to drafts and reload
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
        // editor with new start parameters.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
        // ..
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
        // Reload editor with new message data
44
hgs
parents: 43
diff changeset
   176
        fetchMessageIfNeeded(*mStartParam);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    else {
43
hgs
parents: 40
diff changeset
   179
        NM_ERROR(1,"nmailui: Invalid editor start parameter");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
        // Unused start parameter needs to be deleted
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
        delete startParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        startParam = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
   Screen orientation changed. Editor view needs to be scaled when
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
   landscape <-> portrait switch occurs because text needs to
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
   be wrapped again.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
void NmEditorView::orientationChanged(Qt::Orientation orientation)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
{
43
hgs
parents: 40
diff changeset
   193
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   194
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   195
    Q_UNUSED(orientation);
47
hgs
parents: 44
diff changeset
   196
    
hgs
parents: 44
diff changeset
   197
    // content widget height needs to be set according to the new orientation to get the scroll
hgs
parents: 44
diff changeset
   198
	// area work correctly
hgs
parents: 44
diff changeset
   199
	mHeaderWidget->sendDelayedHeaderHeightChanged();
51
hgs
parents: 49
diff changeset
   200
	mHeaderWidget->adjustHeaderWidth();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
/*!
47
hgs
parents: 44
diff changeset
   204
    This slot is signaled by VKB when it opens
hgs
parents: 44
diff changeset
   205
 */
hgs
parents: 44
diff changeset
   206
void NmEditorView::vkbOpened()
hgs
parents: 44
diff changeset
   207
{
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   208
    showChrome(false);	
47
hgs
parents: 44
diff changeset
   209
}
hgs
parents: 44
diff changeset
   210
hgs
parents: 44
diff changeset
   211
/*!
hgs
parents: 44
diff changeset
   212
    This slot is signaled by VKB when it closes.
hgs
parents: 44
diff changeset
   213
 */
hgs
parents: 44
diff changeset
   214
void NmEditorView::vkbClosed()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
{
47
hgs
parents: 44
diff changeset
   216
	showChrome(true);
hgs
parents: 44
diff changeset
   217
}
hgs
parents: 44
diff changeset
   218
hgs
parents: 44
diff changeset
   219
/*!
hgs
parents: 44
diff changeset
   220
    Hide or show chrome.
hgs
parents: 44
diff changeset
   221
 */
hgs
parents: 44
diff changeset
   222
void NmEditorView::showChrome(bool show)
hgs
parents: 44
diff changeset
   223
{
hgs
parents: 44
diff changeset
   224
    if (show) {
66
hgs
parents: 62
diff changeset
   225
        setContentFullScreen(false);
hgs
parents: 62
diff changeset
   226
        showItems(Hb::ToolBarItem);
47
hgs
parents: 44
diff changeset
   227
    }
hgs
parents: 44
diff changeset
   228
    else {
66
hgs
parents: 62
diff changeset
   229
        setContentFullScreen(true);
hgs
parents: 62
diff changeset
   230
        hideItems(Hb::ToolBarItem);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    View id
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
NmUiViewId NmEditorView::nmailViewId() const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
{
43
hgs
parents: 40
diff changeset
   239
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   240
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    return NmUiViewMessageEditor;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
/*
40
hgs
parents: 23
diff changeset
   245
   Launch dialog for query user if we want to exit the editor
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   246
*/
40
hgs
parents: 23
diff changeset
   247
void NmEditorView::okToExitView()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
{
43
hgs
parents: 40
diff changeset
   249
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   250
       
hgs
parents: 44
diff changeset
   251
    bool okToExit(true);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   252
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   253
    if (mContent) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   254
        NmEditorHeader *header = mContent->header();
47
hgs
parents: 44
diff changeset
   255
        // show the query if the message has not been sent
hgs
parents: 44
diff changeset
   256
        if (mMessage && header) {
hgs
parents: 44
diff changeset
   257
            // see if editor has any content
hgs
parents: 44
diff changeset
   258
            int subjectLength = 0;
hgs
parents: 44
diff changeset
   259
            if (header->subjectEdit()) {
hgs
parents: 44
diff changeset
   260
                subjectLength = header->subjectEdit()->text().length();
40
hgs
parents: 23
diff changeset
   261
            }
47
hgs
parents: 44
diff changeset
   262
            
hgs
parents: 44
diff changeset
   263
            QList<NmMessagePart*> attachmentList;
hgs
parents: 44
diff changeset
   264
            mMessage->attachmentList(attachmentList);
hgs
parents: 44
diff changeset
   265
            
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   266
            if (mContent->editor()) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   267
                okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty());            
47
hgs
parents: 44
diff changeset
   268
            }
hgs
parents: 44
diff changeset
   269
    
hgs
parents: 44
diff changeset
   270
            // content exists, verify exit from user
hgs
parents: 44
diff changeset
   271
            if (!okToExit) {
hgs
parents: 44
diff changeset
   272
                if (mQueryDialog) {
hgs
parents: 44
diff changeset
   273
                    delete mQueryDialog;
hgs
parents: 44
diff changeset
   274
                    mQueryDialog = 0;
hgs
parents: 44
diff changeset
   275
                }
hgs
parents: 44
diff changeset
   276
                // Launch query dialog.
hgs
parents: 44
diff changeset
   277
                mQueryDialog = 
hgs
parents: 44
diff changeset
   278
                    NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
hgs
parents: 44
diff changeset
   279
                                                                this,
hgs
parents: 44
diff changeset
   280
                                                                SLOT(okToExitQuery(HbAction*)));
hgs
parents: 44
diff changeset
   281
            }
hgs
parents: 44
diff changeset
   282
        }    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    }
40
hgs
parents: 23
diff changeset
   284
    
hgs
parents: 23
diff changeset
   285
    // no need to query anything, just exit.
hgs
parents: 23
diff changeset
   286
    if(okToExit) {
hgs
parents: 23
diff changeset
   287
        QMetaObject::invokeMethod(&mApplication,
hgs
parents: 23
diff changeset
   288
                                  "popView",
hgs
parents: 23
diff changeset
   289
                                  Qt::QueuedConnection);
hgs
parents: 23
diff changeset
   290
    }
hgs
parents: 23
diff changeset
   291
}
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
40
hgs
parents: 23
diff changeset
   293
/*!
hgs
parents: 23
diff changeset
   294
    Handle the user selection is it ok to exit.
hgs
parents: 23
diff changeset
   295
*/
47
hgs
parents: 44
diff changeset
   296
void NmEditorView::okToExitQuery(HbAction *action)
40
hgs
parents: 23
diff changeset
   297
{
43
hgs
parents: 40
diff changeset
   298
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   299
    
hgs
parents: 40
diff changeset
   300
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   301
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   302
    if (action == dlg->actions().at(0)) {
62
hgs
parents: 57
diff changeset
   303
        safeToDraft();
43
hgs
parents: 40
diff changeset
   304
    }    
hgs
parents: 40
diff changeset
   305
    
hgs
parents: 40
diff changeset
   306
    // Close the view
hgs
parents: 40
diff changeset
   307
    QMetaObject::invokeMethod(&mApplication,
hgs
parents: 40
diff changeset
   308
                              "popView",
hgs
parents: 40
diff changeset
   309
                              Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
/*!
62
hgs
parents: 57
diff changeset
   313
    Public slot to handle draft saving.
hgs
parents: 57
diff changeset
   314
*/
hgs
parents: 57
diff changeset
   315
void NmEditorView::safeToDraft()
hgs
parents: 57
diff changeset
   316
{
hgs
parents: 57
diff changeset
   317
    // Update draft message with content.
hgs
parents: 57
diff changeset
   318
    updateMessageWithEditorContents();
hgs
parents: 57
diff changeset
   319
hgs
parents: 57
diff changeset
   320
    // Save message to drafts
hgs
parents: 57
diff changeset
   321
    QList<NmOperation *> preliminaryOperations;
hgs
parents: 57
diff changeset
   322
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 57
diff changeset
   323
        preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 57
diff changeset
   324
    }
hgs
parents: 57
diff changeset
   325
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 57
diff changeset
   326
        preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 57
diff changeset
   327
    }
hgs
parents: 57
diff changeset
   328
    // ownership of mMessage is transferred
hgs
parents: 57
diff changeset
   329
    // NmOperations are automatically deleted after completion
hgs
parents: 57
diff changeset
   330
    mUiEngine.saveDraftMessage(mMessage, preliminaryOperations);
hgs
parents: 57
diff changeset
   331
    mMessage = NULL;
hgs
parents: 57
diff changeset
   332
    preliminaryOperations.clear();
hgs
parents: 57
diff changeset
   333
}
hgs
parents: 57
diff changeset
   334
hgs
parents: 57
diff changeset
   335
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    About to exit view. Application calls this function when user has
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
    pressed back key and editor needs to delete the draft message. This is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
    called when "auto-exiting" after a successful mail sending.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
void NmEditorView::aboutToExitView()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
{
43
hgs
parents: 40
diff changeset
   342
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   343
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    // These operations need to be stopped before message can be deleted
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   345
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   346
        mAddAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   347
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   348
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   349
        mRemoveAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   350
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
44
hgs
parents: 43
diff changeset
   352
    if (mMessage) { // this is NULL if sending or saving is started
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
        // Delete message from drafts
43
hgs
parents: 40
diff changeset
   354
        mUiEngine.removeDraftMessage(mMessage);
hgs
parents: 40
diff changeset
   355
        mMessage = NULL;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   360
    Lazy loading when view layout has been loaded
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   361
*/
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   362
void NmEditorView::viewReady()
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   363
{
43
hgs
parents: 40
diff changeset
   364
    NM_FUNCTION;
62
hgs
parents: 57
diff changeset
   365
hgs
parents: 57
diff changeset
   366
    // Set mailbox name to title pane
hgs
parents: 57
diff changeset
   367
    setMailboxName();
43
hgs
parents: 40
diff changeset
   368
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   369
    // Connect options menu about to show to create options menu function
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   370
    // Menu needs to be create "just-in-time"
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   371
    connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu()));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   372
    NmAction *dummy = new NmAction(0);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   373
    menu()->addAction(dummy);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   374
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   375
    mVkbHost = new HbShrinkingVkbHost(this);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   376
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   377
    initializeVKB();
47
hgs
parents: 44
diff changeset
   378
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   379
    //start to listen VKB open and close signals for hiding the chrome.
47
hgs
parents: 44
diff changeset
   380
    connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
hgs
parents: 44
diff changeset
   381
    connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   382
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   383
    connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   384
            this, SLOT(setButtonsDimming(bool)) );
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   385
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   386
    // Connect to observe orientation change events
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   387
    connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   388
            this, SLOT(orientationChanged(Qt::Orientation)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   389
    // Signal for handling the attachment list selection
44
hgs
parents: 43
diff changeset
   390
    connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)),
hgs
parents: 43
diff changeset
   391
            this, SLOT(openAttachmentTriggered(NmId)));
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   392
    connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   393
            this, SLOT(attachmentLongPressed(NmId, QPointF)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   394
    
44
hgs
parents: 43
diff changeset
   395
    if (mStartParam) {
hgs
parents: 43
diff changeset
   396
        fetchMessageIfNeeded(*mStartParam);
hgs
parents: 43
diff changeset
   397
    }
hgs
parents: 43
diff changeset
   398
    else { // execution cannot proceed without start param 
hgs
parents: 43
diff changeset
   399
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 43
diff changeset
   400
    }
62
hgs
parents: 57
diff changeset
   401
    
hgs
parents: 57
diff changeset
   402
    // Adjust the header width according to the current screen width.
hgs
parents: 57
diff changeset
   403
    mHeaderWidget->adjustHeaderWidth(); 
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   404
}
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   405
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   406
/*!
43
hgs
parents: 40
diff changeset
   407
    If entering editor for forwarding or replying, use attachment manager
hgs
parents: 40
diff changeset
   408
    to check that we have all message parts fetched. Also show dialog for
hgs
parents: 40
diff changeset
   409
    fetching progress.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   410
*/
44
hgs
parents: 43
diff changeset
   411
void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
{
43
hgs
parents: 40
diff changeset
   413
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
    
62
hgs
parents: 57
diff changeset
   415
    if (startParam.editorStartMode() == NmUiEditorForward
hgs
parents: 57
diff changeset
   416
        || startParam.editorStartMode()== NmUiEditorReply
hgs
parents: 57
diff changeset
   417
        || startParam.editorStartMode() == NmUiEditorReplyAll) {
hgs
parents: 57
diff changeset
   418
    
hgs
parents: 57
diff changeset
   419
        fetchProgressDialogShow();
hgs
parents: 57
diff changeset
   420
        mAttaManager.clearObserver();
hgs
parents: 57
diff changeset
   421
        mAttaManager.setObserver(this);
hgs
parents: 57
diff changeset
   422
        mAttaManager.fetchAllMessageParts(
hgs
parents: 57
diff changeset
   423
            startParam.mailboxId(),
hgs
parents: 57
diff changeset
   424
            startParam.folderId(),
hgs
parents: 57
diff changeset
   425
            startParam.messageId());
hgs
parents: 57
diff changeset
   426
    }
hgs
parents: 57
diff changeset
   427
    else {
hgs
parents: 57
diff changeset
   428
        startMessageCreation(startParam);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
/*!
43
hgs
parents: 40
diff changeset
   433
    Slot. Called when attachments fetch progress changes.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   434
*/
43
hgs
parents: 40
diff changeset
   435
void NmEditorView::progressChanged(int value)
hgs
parents: 40
diff changeset
   436
{
hgs
parents: 40
diff changeset
   437
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   438
    
hgs
parents: 40
diff changeset
   439
    Q_UNUSED(value);
hgs
parents: 40
diff changeset
   440
}
hgs
parents: 40
diff changeset
   441
hgs
parents: 40
diff changeset
   442
/*!
hgs
parents: 40
diff changeset
   443
    Slot. Called when attachments fetch is completed. We can start
hgs
parents: 40
diff changeset
   444
    message creation. 
hgs
parents: 40
diff changeset
   445
*/
hgs
parents: 40
diff changeset
   446
void NmEditorView::fetchCompleted(int result)
hgs
parents: 40
diff changeset
   447
{
hgs
parents: 40
diff changeset
   448
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   449
    
44
hgs
parents: 43
diff changeset
   450
    if (result == NmNoError && mStartParam) {
hgs
parents: 43
diff changeset
   451
        startMessageCreation(*mStartParam);
43
hgs
parents: 40
diff changeset
   452
    }
hgs
parents: 40
diff changeset
   453
    else {
62
hgs
parents: 57
diff changeset
   454
        // Close "Loading mail content" dialog
hgs
parents: 57
diff changeset
   455
        mWaitDialog->close();
hgs
parents: 57
diff changeset
   456
        
hgs
parents: 57
diff changeset
   457
        // Show a fetching failed note when the failure is not caused by a Device/System failure.
47
hgs
parents: 44
diff changeset
   458
        if (result != NmNoError && 
hgs
parents: 44
diff changeset
   459
            result != NmNotFoundError &&
hgs
parents: 44
diff changeset
   460
            result != NmGeneralError &&
hgs
parents: 44
diff changeset
   461
            result != NmCancelError &&
hgs
parents: 44
diff changeset
   462
            result != NmAuthenticationError &&
hgs
parents: 44
diff changeset
   463
            result != NmServerConnectionError &&
62
hgs
parents: 57
diff changeset
   464
            result != NmConnectionError) {         
hgs
parents: 57
diff changeset
   465
            HbNotificationDialog *note = new HbNotificationDialog();            
47
hgs
parents: 44
diff changeset
   466
            bool enalbeAttribute(true);
62
hgs
parents: 57
diff changeset
   467
            note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute);           
hgs
parents: 57
diff changeset
   468
            note->setIcon(HbIcon(QLatin1String("note_warning")));        
47
hgs
parents: 44
diff changeset
   469
            note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed"));
62
hgs
parents: 57
diff changeset
   470
            note->setTitleTextWrapping(Hb::TextWordWrap);      
47
hgs
parents: 44
diff changeset
   471
            note->setDismissPolicy(HbNotificationDialog::TapAnywhere);
62
hgs
parents: 57
diff changeset
   472
            note->setTimeout(HbNotificationDialog::StandardTimeout);       
47
hgs
parents: 44
diff changeset
   473
            note->setSequentialShow(true);
hgs
parents: 44
diff changeset
   474
            note->show();
hgs
parents: 44
diff changeset
   475
        }
44
hgs
parents: 43
diff changeset
   476
        
62
hgs
parents: 57
diff changeset
   477
        // Go back to Viewer view
43
hgs
parents: 40
diff changeset
   478
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   479
    }
hgs
parents: 40
diff changeset
   480
}
hgs
parents: 40
diff changeset
   481
hgs
parents: 40
diff changeset
   482
void NmEditorView::fetchProgressDialogShow()
hgs
parents: 40
diff changeset
   483
{
hgs
parents: 40
diff changeset
   484
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   485
    
hgs
parents: 40
diff changeset
   486
    delete mWaitDialog;
hgs
parents: 40
diff changeset
   487
    mWaitDialog = NULL;
hgs
parents: 40
diff changeset
   488
    // Create new wait dialog and set it to me modal with dimmed background
hgs
parents: 40
diff changeset
   489
    mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   490
    mWaitDialog->setModal(true);
hgs
parents: 40
diff changeset
   491
    mWaitDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   492
    connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(fetchProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   493
    mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
hgs
parents: 40
diff changeset
   494
    // Display wait dialog
hgs
parents: 40
diff changeset
   495
    mWaitDialog->show();
hgs
parents: 40
diff changeset
   496
}
hgs
parents: 40
diff changeset
   497
hgs
parents: 40
diff changeset
   498
/*!
hgs
parents: 40
diff changeset
   499
    This is called by mFetchProgressDialog when the note is cancelled
hgs
parents: 40
diff changeset
   500
 */
hgs
parents: 40
diff changeset
   501
void NmEditorView::fetchProgressDialogCancelled()
hgs
parents: 40
diff changeset
   502
{
hgs
parents: 40
diff changeset
   503
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   504
    
62
hgs
parents: 57
diff changeset
   505
    if (mAttaManager.isFetching()) { 
43
hgs
parents: 40
diff changeset
   506
        mAttaManager.cancelFetch();
hgs
parents: 40
diff changeset
   507
        mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
   508
    }
62
hgs
parents: 57
diff changeset
   509
    else {   
hgs
parents: 57
diff changeset
   510
        // For those email has no attachment or attachment has fetched.
hgs
parents: 57
diff changeset
   511
        // Go back to Viewer view.
hgs
parents: 57
diff changeset
   512
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 57
diff changeset
   513
    }
43
hgs
parents: 40
diff changeset
   514
}
hgs
parents: 40
diff changeset
   515
44
hgs
parents: 43
diff changeset
   516
void NmEditorView::startMessageCreation(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
{
43
hgs
parents: 40
diff changeset
   518
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   519
    
44
hgs
parents: 43
diff changeset
   520
    NmUiEditorStartMode startMode = startParam.editorStartMode();
hgs
parents: 43
diff changeset
   521
    NmId mailboxId = startParam.mailboxId();
hgs
parents: 43
diff changeset
   522
    NmId folderId = startParam.folderId();
hgs
parents: 43
diff changeset
   523
    NmId msgId = startParam.messageId();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   525
    if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   526
        mMessageCreationOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   527
    }
47
hgs
parents: 44
diff changeset
   528
	  
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   529
    // original message is now fetched so start message creation
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
    if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
        mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
            msgId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
            startMode == NmUiEditorReplyAll);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    }
44
hgs
parents: 43
diff changeset
   538
    else if (startMode == NmUiEditorFromDrafts) {
hgs
parents: 43
diff changeset
   539
        // Draft opened, so reload message and fill editor with message data.
hgs
parents: 43
diff changeset
   540
        mMessage = mUiEngine.message(
hgs
parents: 43
diff changeset
   541
            mStartParam->mailboxId(), 
hgs
parents: 43
diff changeset
   542
            mStartParam->folderId(), 
hgs
parents: 43
diff changeset
   543
            mStartParam->messageId());
hgs
parents: 43
diff changeset
   544
        fillEditorWithMessageContents();
hgs
parents: 43
diff changeset
   545
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
        mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
    // operation continues in messageCreated() once it finishes ok
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    if (mMessageCreationOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
        connect(mMessageCreationOperation,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
                SIGNAL(operationCompleted(int)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
                this,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
                SLOT(messageCreated(int)));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
    }    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
    Starting the message sending is handled here.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   561
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
void NmEditorView::startSending()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
{
43
hgs
parents: 40
diff changeset
   564
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   565
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
    // The message contents should be verified
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
    updateMessageWithEditorContents();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
    // verify addresses before sending
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    QList<NmAddress> invalidAddresses;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   571
    if (mMessage) {
47
hgs
parents: 44
diff changeset
   572
        NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   573
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    if (invalidAddresses.count() > 0) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
        
62
hgs
parents: 57
diff changeset
   577
        // Invalid addresses found, verify send from user.
hgs
parents: 57
diff changeset
   578
        // Set the first failing address to the note.
hgs
parents: 57
diff changeset
   579
        QString noteText = 
hgs
parents: 57
diff changeset
   580
            HbParameterLengthLimiter(
hgs
parents: 57
diff changeset
   581
                "txt_mail_dialog_invalid_mail_address_send"
hgs
parents: 57
diff changeset
   582
                ).arg(invalidAddresses.at(0).address());
40
hgs
parents: 23
diff changeset
   583
        
hgs
parents: 23
diff changeset
   584
        if (mQueryDialog) {
hgs
parents: 23
diff changeset
   585
            delete mQueryDialog;
hgs
parents: 23
diff changeset
   586
            mQueryDialog = 0;
hgs
parents: 23
diff changeset
   587
        }
hgs
parents: 23
diff changeset
   588
        // Launch query dialog. Pressing "yes" will finalize the sending.
hgs
parents: 23
diff changeset
   589
        mQueryDialog = NmUtilities::displayQuestionNote(noteText,
hgs
parents: 23
diff changeset
   590
                                                        this,
hgs
parents: 23
diff changeset
   591
                                                        SLOT(invalidAddressQuery(HbAction*)));
hgs
parents: 23
diff changeset
   592
    }
hgs
parents: 23
diff changeset
   593
    else {
hgs
parents: 23
diff changeset
   594
        // no need to ask anything, just send
hgs
parents: 23
diff changeset
   595
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
    }
40
hgs
parents: 23
diff changeset
   597
}
hgs
parents: 23
diff changeset
   598
hgs
parents: 23
diff changeset
   599
/*!
hgs
parents: 23
diff changeset
   600
    Send the message after all checks have been done.
hgs
parents: 23
diff changeset
   601
*/
hgs
parents: 23
diff changeset
   602
void NmEditorView::finalizeSending()
hgs
parents: 23
diff changeset
   603
{
43
hgs
parents: 40
diff changeset
   604
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   605
    
40
hgs
parents: 23
diff changeset
   606
    QList<NmOperation *> preliminaryOperations;
43
hgs
parents: 40
diff changeset
   607
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   608
        preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 40
diff changeset
   609
    }
hgs
parents: 40
diff changeset
   610
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   611
        preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 40
diff changeset
   612
    }
40
hgs
parents: 23
diff changeset
   613
    // ownership of mMessage is transferred
hgs
parents: 23
diff changeset
   614
    // NmOperations are automatically deleted after completion
hgs
parents: 23
diff changeset
   615
    mUiEngine.sendMessage(mMessage, preliminaryOperations);
hgs
parents: 23
diff changeset
   616
    mMessage = NULL;
hgs
parents: 23
diff changeset
   617
    preliminaryOperations.clear();
43
hgs
parents: 40
diff changeset
   618
hgs
parents: 40
diff changeset
   619
    bool service = XQServiceUtil::isService();
hgs
parents: 40
diff changeset
   620
hgs
parents: 40
diff changeset
   621
    // If sending is started as a service, progress dialog needs to be shown
hgs
parents: 40
diff changeset
   622
    // so long that sending is finished otherwise we can close pop current view.
44
hgs
parents: 43
diff changeset
   623
    if (service && mStartParam && mStartParam->service() && 
hgs
parents: 43
diff changeset
   624
        mUiEngine.isSendingMessage()) {
43
hgs
parents: 40
diff changeset
   625
        connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
hgs
parents: 40
diff changeset
   626
            this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
hgs
parents: 40
diff changeset
   627
hgs
parents: 40
diff changeset
   628
        // Construct and setup the wait dialog.
hgs
parents: 40
diff changeset
   629
        mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   630
        mServiceSendingDialog->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 40
diff changeset
   631
        mServiceSendingDialog->setText(hbTrId("txt_mail_shareui_sending_please_wait"));
hgs
parents: 40
diff changeset
   632
        connect(mServiceSendingDialog, SIGNAL(cancelled()),
hgs
parents: 40
diff changeset
   633
            this, SLOT(sendProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   634
hgs
parents: 40
diff changeset
   635
        if (!XQServiceUtil::isEmbedded()) {
hgs
parents: 40
diff changeset
   636
            // Hide the application.
hgs
parents: 40
diff changeset
   637
            XQServiceUtil::toBackground(true);
hgs
parents: 40
diff changeset
   638
        }
hgs
parents: 40
diff changeset
   639
         // Display the wait dialog.
hgs
parents: 40
diff changeset
   640
         mServiceSendingDialog->setModal(true);
hgs
parents: 40
diff changeset
   641
         mServiceSendingDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   642
         mServiceSendingDialog->show();
hgs
parents: 40
diff changeset
   643
    } else {
hgs
parents: 40
diff changeset
   644
        // Must use delayed editor view destruction so that query dialog
hgs
parents: 40
diff changeset
   645
        // (which has signaled this) gets time to complete.
hgs
parents: 40
diff changeset
   646
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   647
    }
40
hgs
parents: 23
diff changeset
   648
}
hgs
parents: 23
diff changeset
   649
hgs
parents: 23
diff changeset
   650
/*!
hgs
parents: 23
diff changeset
   651
    Handle the user selection for invalid address query which was started by startSending.
hgs
parents: 23
diff changeset
   652
*/
hgs
parents: 23
diff changeset
   653
void NmEditorView::invalidAddressQuery(HbAction* action)
hgs
parents: 23
diff changeset
   654
{
43
hgs
parents: 40
diff changeset
   655
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   656
hgs
parents: 40
diff changeset
   657
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   658
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   659
    if (action == dlg->actions().at(0)) {
40
hgs
parents: 23
diff changeset
   660
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
/*!
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   665
    This is called when the view's geometry size has been changed, eg. when VKB is opened/closed.
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   666
*/
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   667
void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event)
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   668
{
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   669
    NM_FUNCTION;
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   670
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   671
    NmBaseView::resizeEvent(event);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   672
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   673
    emit sizeChanged();
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   674
}
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   675
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   676
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
    This is signalled by mMessageCreationOperation when message is created.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   678
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
void NmEditorView::messageCreated(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
{
43
hgs
parents: 40
diff changeset
   681
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   682
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
    delete mMessage;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
    mMessage = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
43
hgs
parents: 40
diff changeset
   686
    // Close wait dialog here
hgs
parents: 40
diff changeset
   687
    if (mWaitDialog) {
hgs
parents: 40
diff changeset
   688
        mWaitDialog->close();
hgs
parents: 40
diff changeset
   689
    }
hgs
parents: 40
diff changeset
   690
    
44
hgs
parents: 43
diff changeset
   691
    if (result == NmNoError && mStartParam && mMessageCreationOperation) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
        NmUiEditorStartMode startMode = mStartParam->editorStartMode();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
        // get message "again" from engine to update the message contents 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
        mMessage = mUiEngine.message(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
            mStartParam->mailboxId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
            mStartParam->folderId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
            mMessageCreationOperation->getMessageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
        fillEditorWithMessageContents();       
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
   Updates the message with the editor contents.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   706
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
void NmEditorView::updateMessageWithEditorContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
{
43
hgs
parents: 40
diff changeset
   709
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   710
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    if (mMessage) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   712
        if (mContent && mContent->editor()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
            NmMessagePart* bodyPart = mMessage->htmlBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   715
                bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
            bodyPart = mMessage->plainTextBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   719
                bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
        }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   722
        if (mContent && mContent->header() ) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   723
            if (mContent->header()->subjectEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
                mMessage->envelope().setSubject(
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   725
                    mContent->header()->subjectEdit()->text());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   727
            if (mContent->header()->toEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
                QString toFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   729
                    mContent->header()->toEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
                // This verification of zero length string isn't needed
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
                // after list of addresses
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
                if (toFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   734
                    mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   737
            if (mContent->header()->ccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
                QString ccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   739
                    mContent->header()->ccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
                if (ccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   742
                    mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList());      
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   745
            if (mContent->header()->bccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
                QString bccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   747
                    mContent->header()->bccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
                if (bccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   750
                    mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
    Updates the message with the editor contents. Called only once when the
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
    editor is launched.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   761
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
void NmEditorView::fillEditorWithMessageContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
{
43
hgs
parents: 40
diff changeset
   764
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   765
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   766
    if (!mStartParam || !mMessage || !mContent) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
        return;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
    NmMessageEnvelope messageEnvelope(mMessage->envelope());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
    bool useStartParam(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
44
hgs
parents: 43
diff changeset
   773
    NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
44
hgs
parents: 43
diff changeset
   775
    if (editorStartMode == NmUiEditorMailto) {
hgs
parents: 43
diff changeset
   776
        // Retrieve the message header data e.g. recipients from mStartParam.
hgs
parents: 43
diff changeset
   777
        useStartParam = true;        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
    // Set recipients (to, cc and bcc).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    QString toAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
    QString ccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
    QString bccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
        toAddressesString = addressListToString(mStartParam->mailtoAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
        ccAddressesString = addressListToString(mStartParam->ccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
        bccAddressesString = addressListToString(mStartParam->bccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
        toAddressesString = addressListToString(messageEnvelope.toRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
        ccAddressesString = addressListToString(messageEnvelope.ccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
        bccAddressesString = addressListToString(messageEnvelope.bccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   796
    mContent->header()->toEdit()->setPlainText(toAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   797
    mContent->header()->ccEdit()->setPlainText(ccAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   798
    mContent->header()->bccEdit()->setPlainText(bccAddressesString);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
    if (ccAddressesString.length() || bccAddressesString.length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
        // Since cc or/and bcc recipients exist, expand the group box to display
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
        // the addresses by expanding the group box.
62
hgs
parents: 57
diff changeset
   803
        mCcBccFieldVisible = true;
hgs
parents: 57
diff changeset
   804
        mHeaderWidget->setFieldVisibility(mCcBccFieldVisible);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
    // Set subject.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
        QString *subject = mStartParam->subject();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
        if (subject) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   812
            mContent->header()->subjectEdit()->setPlainText(*subject);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
        // Construct the subject field.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   817
        mContent->header()->subjectEdit()->setPlainText(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
            addSubjectPrefix(editorStartMode, messageEnvelope.subject()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
    // Set priority.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   822
    if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   823
        //Clear the importance flag. Replied messages dont keep the importance
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   824
        setPriority(NmActionResponseCommandNone);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   825
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
    mHeaderWidget->setPriority(messageEnvelope.priority());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
    
62
hgs
parents: 57
diff changeset
   828
    NmMessage *originalMessage = NULL;
hgs
parents: 57
diff changeset
   829
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
    // Set the message body.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   831
    if (editorStartMode==NmUiEditorReply||
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   832
        editorStartMode==NmUiEditorReplyAll||
44
hgs
parents: 43
diff changeset
   833
        editorStartMode==NmUiEditorForward||
hgs
parents: 43
diff changeset
   834
        editorStartMode==NmUiEditorFromDrafts){
43
hgs
parents: 40
diff changeset
   835
hgs
parents: 40
diff changeset
   836
        // Use the body from the original message.
62
hgs
parents: 57
diff changeset
   837
        originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
hgs
parents: 57
diff changeset
   838
                                            mStartParam->folderId(), 
hgs
parents: 57
diff changeset
   839
                                            mStartParam->messageId());
43
hgs
parents: 40
diff changeset
   840
hgs
parents: 40
diff changeset
   841
        if (originalMessage) {
hgs
parents: 40
diff changeset
   842
            NmMessagePart *plainPart = originalMessage->plainTextBodyPart();
hgs
parents: 40
diff changeset
   843
hgs
parents: 40
diff changeset
   844
            if (plainPart) {
hgs
parents: 40
diff changeset
   845
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   846
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   847
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   848
                                               *plainPart);
hgs
parents: 40
diff changeset
   849
            }
hgs
parents: 40
diff changeset
   850
hgs
parents: 40
diff changeset
   851
            NmMessagePart *htmlPart = originalMessage->htmlBodyPart();
hgs
parents: 40
diff changeset
   852
hgs
parents: 40
diff changeset
   853
            if (htmlPart) {
hgs
parents: 40
diff changeset
   854
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   855
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   856
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   857
                                               *htmlPart);
hgs
parents: 40
diff changeset
   858
            }
hgs
parents: 40
diff changeset
   859
hgs
parents: 40
diff changeset
   860
        }
hgs
parents: 40
diff changeset
   861
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   862
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
    
62
hgs
parents: 57
diff changeset
   864
    QString *signature = NULL;
hgs
parents: 57
diff changeset
   865
    // return value is not relevant here
hgs
parents: 57
diff changeset
   866
    mUiEngine.getSignature(mStartParam->mailboxId(), signature);
hgs
parents: 57
diff changeset
   867
    
hgs
parents: 57
diff changeset
   868
    mContent->setBodyContent(editorStartMode, originalMessage, signature);
hgs
parents: 57
diff changeset
   869
hgs
parents: 57
diff changeset
   870
    delete signature;
hgs
parents: 57
diff changeset
   871
    signature = NULL;
hgs
parents: 57
diff changeset
   872
hgs
parents: 57
diff changeset
   873
    delete originalMessage;
hgs
parents: 57
diff changeset
   874
    originalMessage = NULL;
hgs
parents: 57
diff changeset
   875
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
    // Get list of attachments from the message and set those into UI attachment list
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
    QList<NmMessagePart*> attachments;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
    mMessage->attachmentList(attachments);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    for (int i=0; i<attachments.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
        mHeaderWidget->addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
            attachments[i]->attachmentName(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
            QString::number(attachments[i]->size()),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   884
            attachments[i]->partId());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
44
hgs
parents: 43
diff changeset
   887
    // Attach passed files to the message.
hgs
parents: 43
diff changeset
   888
    QStringList *fileList = mStartParam->attachmentList();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
44
hgs
parents: 43
diff changeset
   890
    if (fileList) {
hgs
parents: 43
diff changeset
   891
        addAttachments(*fileList);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
    createToolBar. Function asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
    to be added to toolbar owned by the HbView.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
void NmEditorView::createToolBar()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
{
43
hgs
parents: 40
diff changeset
   903
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   904
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
    if (tb && &extMngr && mStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
        tb->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
        NmActionRequest request(this, NmActionToolbar, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
                NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
            tb->addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
            // If action has NmSendable condition, it is shown only when send action
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
            // is available, i.e. when at least one recipient field has data.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
            }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   920
            else if (list[i]->availabilityCondition() == NmAction::NmAttachable) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   921
                HbToolBarExtension* extension = new HbToolBarExtension();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   922
                mAttachmentPicker = new NmAttachmentPicker(this);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   923
                
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   924
                if (extension && mAttachmentPicker) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   925
                    connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
62
hgs
parents: 57
diff changeset
   926
                        this, SLOT(onAttachmentReqCompleted(const QVariant &)));
56
hgs
parents: 51
diff changeset
   927
                    
62
hgs
parents: 57
diff changeset
   928
                    connect(this, SIGNAL(titleChanged(QString)), mAttachmentPicker,
hgs
parents: 57
diff changeset
   929
                        SLOT(setTitle(QString)));
hgs
parents: 57
diff changeset
   930
56
hgs
parents: 51
diff changeset
   931
                    list[i]->setToolBarExtension(extension);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   932
                    
56
hgs
parents: 51
diff changeset
   933
                    //content widget to get the items to a list
hgs
parents: 51
diff changeset
   934
                    mTBExtnContentWidget = new HbListWidget();
hgs
parents: 51
diff changeset
   935
                    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
43
hgs
parents: 40
diff changeset
   936
                    
56
hgs
parents: 51
diff changeset
   937
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo"));
66
hgs
parents: 62
diff changeset
   938
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_sound"));
56
hgs
parents: 51
diff changeset
   939
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video"));
hgs
parents: 51
diff changeset
   940
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other"));
hgs
parents: 51
diff changeset
   941
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo"));
hgs
parents: 51
diff changeset
   942
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video"));
hgs
parents: 51
diff changeset
   943
                    HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype();
hgs
parents: 51
diff changeset
   944
                    HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces);
hgs
parents: 51
diff changeset
   945
                    listView->setDefaultFrame(frame);
43
hgs
parents: 40
diff changeset
   946
                    
56
hgs
parents: 51
diff changeset
   947
                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), 
hgs
parents: 51
diff changeset
   948
                    		mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*)));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   949
            
56
hgs
parents: 51
diff changeset
   950
                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
hgs
parents: 51
diff changeset
   951
                            extension, SLOT(close()));
43
hgs
parents: 40
diff changeset
   952
                                        
56
hgs
parents: 51
diff changeset
   953
                    extension->setContentWidget(mTBExtnContentWidget);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   954
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   955
            }            
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   956
        }        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
    createOptionsMenu. Functions asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
    to be added to options menu.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
void NmEditorView::createOptionsMenu()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
{
43
hgs
parents: 40
diff changeset
   966
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   967
    
40
hgs
parents: 23
diff changeset
   968
    menu()->clearActions();
hgs
parents: 23
diff changeset
   969
hgs
parents: 23
diff changeset
   970
	// Create CC/BCC options menu object
hgs
parents: 23
diff changeset
   971
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
   972
        menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   973
    }
hgs
parents: 23
diff changeset
   974
    else {
hgs
parents: 23
diff changeset
   975
        menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   976
    }
hgs
parents: 23
diff changeset
   977
hgs
parents: 23
diff changeset
   978
	// Create Priority options menu object
hgs
parents: 23
diff changeset
   979
	if (!mPrioritySubMenu) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
        mPrioritySubMenu = new HbMenu();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
    mPrioritySubMenu->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
    NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
            NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
            mStartParam->messageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
    QList<NmAction*> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
    extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
    for (int i = 0; i < list.count(); i++) {
57
hgs
parents: 56
diff changeset
   990
        // check what priority has already been selected and hide it from options menu
hgs
parents: 56
diff changeset
   991
        if (!list[i]->objectName().contains(mHiddenPriorityName)) {
hgs
parents: 56
diff changeset
   992
            mPrioritySubMenu->addAction(list[i]);
hgs
parents: 56
diff changeset
   993
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
    mPrioritySubMenu->setObjectName("editorPrioritySubMenu");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
    mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority"));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   997
    menu()->addMenu(mPrioritySubMenu);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   998
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
/*!
40
hgs
parents: 23
diff changeset
  1001
    Show or hide Cc field
hgs
parents: 23
diff changeset
  1002
*/
hgs
parents: 23
diff changeset
  1003
void NmEditorView::switchCcBccFieldVisibility()
hgs
parents: 23
diff changeset
  1004
{
43
hgs
parents: 40
diff changeset
  1005
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1006
    
40
hgs
parents: 23
diff changeset
  1007
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
  1008
    	mCcBccFieldVisible = false;
hgs
parents: 23
diff changeset
  1009
    }
hgs
parents: 23
diff changeset
  1010
    else {
hgs
parents: 23
diff changeset
  1011
    	mCcBccFieldVisible = true;
hgs
parents: 23
diff changeset
  1012
    }
hgs
parents: 23
diff changeset
  1013
    mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
hgs
parents: 23
diff changeset
  1014
}
hgs
parents: 23
diff changeset
  1015
hgs
parents: 23
diff changeset
  1016
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1017
    handleActionCommand. From NmActionObserver, extension manager calls this
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1018
    call to handle menu command in the UI.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1020
void NmEditorView::handleActionCommand(NmActionResponse &actionResponse)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
{
43
hgs
parents: 40
diff changeset
  1022
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1023
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
    NmActionResponseCommand responseCommand = actionResponse.responseCommand();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
    // Handle options menu
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
    if (actionResponse.menuType() == NmActionOptionsMenu) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1028
        setPriority(responseCommand);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
    else if (actionResponse.menuType() == NmActionToolbar) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
        switch (responseCommand) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1032
        case NmActionResponseCommandSendMail: {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1033
            // Just in case send mail would be somehow accessible during message creation or
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1034
            // outobox checking
43
hgs
parents: 40
diff changeset
  1035
            if (!mMessageCreationOperation || !mMessageCreationOperation->isRunning()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
                startSending();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
            }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1038
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1039
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1040
        default:
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1041
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1042
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1043
    }
40
hgs
parents: 23
diff changeset
  1044
    else if (actionResponse.menuType() == NmActionContextMenu) {
hgs
parents: 23
diff changeset
  1045
        switch (responseCommand) {
hgs
parents: 23
diff changeset
  1046
        case NmActionResponseCommandRemoveAttachment: {
hgs
parents: 23
diff changeset
  1047
            removeAttachmentTriggered();
hgs
parents: 23
diff changeset
  1048
            break;
hgs
parents: 23
diff changeset
  1049
        }
hgs
parents: 23
diff changeset
  1050
        case NmActionResponseCommandOpenAttachment: {
44
hgs
parents: 43
diff changeset
  1051
            openAttachmentTriggered(mSelectedAttachment);
40
hgs
parents: 23
diff changeset
  1052
            break;
hgs
parents: 23
diff changeset
  1053
        }
hgs
parents: 23
diff changeset
  1054
        default:
hgs
parents: 23
diff changeset
  1055
            break;
hgs
parents: 23
diff changeset
  1056
        }
hgs
parents: 23
diff changeset
  1057
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1058
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
/*!
43
hgs
parents: 40
diff changeset
  1061
    Slot. Cancelled sending progress dialog.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1062
*/
43
hgs
parents: 40
diff changeset
  1063
void NmEditorView::sendProgressDialogCancelled()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
{
43
hgs
parents: 40
diff changeset
  1065
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1066
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1067
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1068
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1069
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1070
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1071
   Sets all toolbar and VKB buttons dimmed state. All actions that have the
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
   availability condition NmSendable set, will be enabled/disabled.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1074
void NmEditorView::setButtonsDimming(bool enabled)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
{
43
hgs
parents: 40
diff changeset
  1076
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1077
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
    // Set the toolbar action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    if (tb) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
        QList<QAction *> toolbarList = tb->actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
        int count = toolbarList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
            NmAction *action = static_cast<NmAction *>(toolbarList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
                action->setEnabled(enabled);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
        // Set the VKB action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
        // All editors of the view share the same action, so it is enough to set
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
        // this only to one of them.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1093
        HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
        QList<HbAction *> vkbList = editorInterface.actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1095
        count = vkbList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
            NmAction *action = static_cast<NmAction *>(vkbList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
                action->setEnabled(enabled);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1100
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1102
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1106
    Initialize the Virtual Keyboard to show the "Send" button
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1107
    for all editors of the view.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
void NmEditorView::initializeVKB()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
{
43
hgs
parents: 40
diff changeset
  1111
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1112
    
44
hgs
parents: 43
diff changeset
  1113
    if (!mStartParam) {
hgs
parents: 43
diff changeset
  1114
        return;
hgs
parents: 43
diff changeset
  1115
    }
hgs
parents: 43
diff changeset
  1116
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1117
    NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
         NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
    if (&extMngr) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
        // VKB only supports one application key, but the responsibility of giving only one
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
        // action is left to the extension plugin. The rest are still attached to the VKB, but
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
        // they are not shown (unless VKB starts supporting more than one).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
            list[i]->setIcon(NmIcons::getIcon(NmIcons::NmIconSend));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1132
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
            // Link VKB to the action. This must be done to all
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1134
            // editors that show the button in VKB.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1135
            HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
            editorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1137
            HbEditorInterface toEditorInterface(mContent->header()->toEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
            toEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1139
            HbEditorInterface ccEditorInterface(mContent->header()->ccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1140
            ccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1141
            HbEditorInterface bccEditorInterface(mContent->header()->bccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
            bccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1143
            HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1144
            subjectEditorInterface.addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
    Set mailbox name to title
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
void NmEditorView::setMailboxName()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
{
43
hgs
parents: 40
diff changeset
  1154
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1155
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
    if (mStartParam){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
        NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
        if (meta){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
            setTitle(meta->name());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1162
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
   Adds a prefix to the subject for reply or forward. 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
   Strips other occurrences of the prefix from the beginning.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1167
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject )
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
{
43
hgs
parents: 40
diff changeset
  1170
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1171
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
    QString newSubject(subject.trimmed());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
    if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
        startMode == NmUiEditorForward) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1176
        QString rePrefix(hbTrId("txt_nmailui_reply_subject_prefix"));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1177
        QString fwPrefix(hbTrId("txt_nmailui_forward_subject_prefix"));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
        // strip extra prefixes from beginning
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
        int rePrefixLength(rePrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
        int fwPrefixLength(fwPrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1183
        bool startswithRe(newSubject.startsWith(rePrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
        bool startswithFw(newSubject.startsWith(fwPrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1185
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1186
        while (startswithRe || startswithFw) {            
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1187
            if (startswithRe) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1188
                newSubject.remove(0,rePrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
                newSubject = newSubject.trimmed();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
            else if (startswithFw) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1192
                newSubject.remove(0,fwPrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1193
                newSubject = newSubject.trimmed();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1194
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
            startswithRe = newSubject.startsWith(rePrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
            startswithFw = newSubject.startsWith(fwPrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
        if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
            newSubject = rePrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1201
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
        else if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
            newSubject = fwPrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
    return newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1209
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
    This slot is called when 'attachment picker' request has been performed succesfully
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
    Parameter 'value' contains file currently one file name but later list of the files. 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
void NmEditorView::onAttachmentReqCompleted(const QVariant &value)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
{
43
hgs
parents: 40
diff changeset
  1217
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1218
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1219
    //temporary fix for music picker back button:
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1220
    //it shouldn't emit requestOk signal when nothing is selected
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1221
	if (value.canConvert<QStringList>()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1222
	    QStringList list = value.toStringList();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1223
        if (!list.at(0).isEmpty()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1224
            addAttachments(list);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1225
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
43
hgs
parents: 40
diff changeset
  1229
/*!
hgs
parents: 40
diff changeset
  1230
    This slot is called when 'attachment picker' request has been unsuccesfull
hgs
parents: 40
diff changeset
  1231
    Parameter 'errorCode' is the error code returned by the service
hgs
parents: 40
diff changeset
  1232
    Parameter 'errorMessage' is the error message returned by the service
hgs
parents: 40
diff changeset
  1233
*/
hgs
parents: 40
diff changeset
  1234
void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
hgs
parents: 40
diff changeset
  1235
{
hgs
parents: 40
diff changeset
  1236
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1237
    Q_UNUSED(errorCode);
hgs
parents: 43
diff changeset
  1238
    Q_UNUSED(errorMessage);
43
hgs
parents: 40
diff changeset
  1239
    NM_COMMENT(QString("Error code: %1").arg(errorCode));
hgs
parents: 40
diff changeset
  1240
    NM_COMMENT(QString("Error message: %1").arg(errorMessage));
hgs
parents: 40
diff changeset
  1241
}
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1242
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1243
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1244
    Closes the wait dialog if one exists.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1245
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1246
    This slot is called if the mail application has been started as a service
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1247
    and is about to close. Closing the application while still sending a message
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1248
    may cause unwanted cancelling of the operation.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1249
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1250
void NmEditorView::handleSendOperationCompleted()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1251
{
43
hgs
parents: 40
diff changeset
  1252
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1253
hgs
parents: 40
diff changeset
  1254
    if (mServiceSendingDialog) {
hgs
parents: 40
diff changeset
  1255
        mServiceSendingDialog->close();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1256
    }
43
hgs
parents: 40
diff changeset
  1257
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1258
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1259
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1260
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1261
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
    Add list of attachments
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
void NmEditorView::addAttachments(const QStringList& fileNames) 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
{
43
hgs
parents: 40
diff changeset
  1267
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1268
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
    // Add attachment name into UI
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1270
    foreach (QString fileName, fileNames)  {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1271
        // At this phase attachment size and nmid are not known
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
        mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0));
43
hgs
parents: 40
diff changeset
  1273
        NM_COMMENT(fileName);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1275
    //  Cancel previous operation if it's not running.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
    if (mAddAttachmentOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
        if (!mAddAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1278
            mAddAttachmentOperation->cancelOperation();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1279
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1280
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1281
    // Start operation to attach file or list of files into mail message.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1282
    // This will also copy files into message store.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1283
    mAddAttachmentOperation = mUiEngine.addAttachments(*mMessage, fileNames);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1285
    if (mAddAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1286
        enableToolBarAttach(false);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1287
        // Signal to inform completion of one attachment
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1288
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1289
                SIGNAL(operationPartCompleted(const QString &, const NmId &, int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1290
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1291
                SLOT(oneAttachmentAdded(const QString &, const NmId &, int)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1292
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1293
        // Signal to inform the completion of the whole operation
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1294
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1295
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1296
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1297
                SLOT(allAttachmentsAdded(int)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1299
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1300
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1302
    This slot is called to create context menu when attachment has been selected
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1303
    from UI by longpress.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
*/
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1305
void NmEditorView::attachmentLongPressed(NmId attachmentPartId, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
{
43
hgs
parents: 40
diff changeset
  1307
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1308
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1309
    // Store id of the attachment to be removed into member.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1310
    // It is used by removeAttachmentTriggered later if 'remove' selected.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1311
    mSelectedAttachment = attachmentPartId;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1312
	
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1313
    if (!mAttachmentListContextMenu) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1314
        mAttachmentListContextMenu = new HbMenu();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1315
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1316
    mAttachmentListContextMenu->clearActions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1317
    NmActionRequest request(this, NmActionContextMenu, NmActionContextViewEditor,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1318
        NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1319
        mStartParam->messageId());
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1320
    NmUiExtensionManager &extensionManager = mApplication.extManager();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1321
    if (&extensionManager) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1322
        QList<NmAction*> actionList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1323
        extensionManager.getActions(request, actionList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1324
        for (int i = 0; i < actionList.count(); ++i) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1325
            mAttachmentListContextMenu->addAction(actionList[i]);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1326
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1327
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1328
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1329
    // Add menu position check here, so that it does not go outside of the screen
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1330
    QPointF menuPos(point.x(),point.y());
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1331
    mAttachmentListContextMenu->setPreferredPos(menuPos);
40
hgs
parents: 23
diff changeset
  1332
    mAttachmentListContextMenu->open();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1333
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1334
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1335
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
    This is signalled by mAddAttachmentOperation when the operation is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1337
    completed for one attachment.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1338
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1339
void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1340
{
43
hgs
parents: 40
diff changeset
  1341
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1342
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1343
    if (result == NmNoError && mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1344
        // Need to get the message again because new attachment part has been added.
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1345
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1346
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1347
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1348
        NmMessagePriority messagePriority = mMessage->envelope().priority();        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1349
        
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1350
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1351
        mMessage = NULL;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1352
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1353
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1354
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1355
        if (mMessage) {
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1356
            mMessage->envelope().setPriority(messagePriority);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1357
            mMessage->envelope().setHasAttachments(true);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1358
            // Get attachment list from the message
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1359
            QList<NmMessagePart*> attachmentList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1360
            mMessage->attachmentList(attachmentList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1361
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1362
            // Search newly added attachment from the list
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1363
            for (int i=0; i<attachmentList.count(); i++) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1364
                if (attachmentList[i]->partId() == msgPartId) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1365
                    // Get attachment file size and set it into UI
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1366
                    mHeaderWidget->setAttachmentParameters(fileName,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1367
                        msgPartId,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1368
                        QString().setNum(attachmentList[i]->size()),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1369
                        result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1370
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1371
            }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1372
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1374
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
        // Attachment adding failed. Show an error note and remove from UI attachment list.
43
hgs
parents: 40
diff changeset
  1376
        NM_ERROR(1,QString("nmailui: attachment adding into message failed: %1").arg(fileName));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1377
        mHeaderWidget->removeAttachment(fileName);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
    This is signalled by mAddAttachmentOperation when the operation is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
    completed totally.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1384
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
void NmEditorView::allAttachmentsAdded(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
{
43
hgs
parents: 40
diff changeset
  1387
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1388
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1389
    enableToolBarAttach(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
    if (result != NmNoError) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1391
        NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment"));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1392
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1393
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
   Sets priority for the message object that is being edited 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
void NmEditorView::setPriority(NmActionResponseCommand priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
{
43
hgs
parents: 40
diff changeset
  1400
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1401
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
    mHeaderWidget->setPriority(priority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1403
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
    if (mMessage) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1405
        NmMessagePriority messagePriority = NmMessagePriorityNormal;
57
hgs
parents: 56
diff changeset
  1406
        mHiddenPriorityName = NmPriorityNormal;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
        if (priority == NmActionResponseCommandPriorityHigh) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
            messagePriority = NmMessagePriorityHigh;
57
hgs
parents: 56
diff changeset
  1410
            mHiddenPriorityName = NmPriorityHigh;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1411
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
        else if (priority == NmActionResponseCommandPriorityLow) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
            messagePriority = NmMessagePriorityLow;
57
hgs
parents: 56
diff changeset
  1414
            mHiddenPriorityName = NmPriorityLow;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
        mMessage->envelope().setPriority(messagePriority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1418
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1419
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1420
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1421
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1422
    Extracts the addresses from the given list into a string separated with a
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1423
    delimiter.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1424
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1426
    \return String containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1427
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
{
43
hgs
parents: 40
diff changeset
  1430
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1431
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1432
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1433
    QList<NmAddress*>::const_iterator i = list.constBegin();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1434
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1435
    while (i != list.constEnd() && *i) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1436
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1437
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1438
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1439
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1440
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1441
        addressesString += (*i)->address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1442
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1443
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1444
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1445
    return addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1446
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1447
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1448
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1449
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1450
    Extracts the addresses from the given list into a string separated with a
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1451
    delimiter.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1452
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1453
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1454
    \return String containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1455
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1456
QString NmEditorView::addressListToString(const QList<NmAddress> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1457
{
43
hgs
parents: 40
diff changeset
  1458
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1459
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1460
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1461
    QList<NmAddress>::const_iterator i = list.constBegin();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1462
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1463
    while (i != list.constEnd()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1464
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1465
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1466
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1467
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1468
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1469
        addressesString += (*i).address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1470
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1471
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1472
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1473
    return addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1474
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1475
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1476
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1477
    This slot is called when 'remove' is selected from attachment list context menu.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1478
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1479
void NmEditorView::removeAttachmentTriggered()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1480
{
43
hgs
parents: 40
diff changeset
  1481
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1482
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1483
    // Cancel will delete previous operation
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1484
    if (mRemoveAttachmentOperation) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1485
        if (!mRemoveAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1486
            mRemoveAttachmentOperation->cancelOperation();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1487
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1488
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1489
    // Remove from UI
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1490
    mHeaderWidget->removeAttachment(mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1491
    // Remove from message store
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1492
    mRemoveAttachmentOperation = mUiEngine.removeAttachment(*mMessage, mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1493
    if (mRemoveAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1494
        // Signal to inform the remove operation completion
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1495
        connect(mRemoveAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1496
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1497
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1498
                SLOT(attachmentRemoved(int)));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1499
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1500
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1501
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1502
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1503
    This slot is called by mRemoveAttachmentOperation when the operation is
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1504
    completed. There is no need to update UI because it was already updated.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1505
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1506
void NmEditorView::attachmentRemoved(int result)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1507
{
43
hgs
parents: 40
diff changeset
  1508
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1509
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1510
    // It is not desided yet what to do if operation fails
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1511
    Q_UNUSED(result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1512
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1513
    if (mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1514
        // Reload message because one attachment has been removed
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1515
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1516
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1517
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1518
        NmMessagePriority messagePriority = mMessage->envelope().priority();    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1519
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1520
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1521
        mMessage = NULL;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1522
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1523
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1524
        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1525
        if(mMessage) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1526
            // Set the correct priority
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1527
            mMessage->envelope().setPriority(messagePriority);    
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1528
            
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1529
            // If there is no more attachments in the message, set the correct value
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1530
            QList<NmMessagePart*> attachmentList;
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1531
            mMessage->attachmentList(attachmentList);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1532
            if(attachmentList.count() == 0) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1533
                mMessage->envelope().setHasAttachments(false);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1534
            }
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1535
        }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1536
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1537
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1538
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1539
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1540
    This slot is called when 'open' is selected from attachment list context menu.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1541
*/
44
hgs
parents: 43
diff changeset
  1542
void NmEditorView::openAttachmentTriggered(NmId attachmentId)
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1543
{
43
hgs
parents: 40
diff changeset
  1544
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1545
    NmId mailboxId = mMessage->envelope().mailboxId();
hgs
parents: 43
diff changeset
  1546
    NmId folderId = mMessage->envelope().folderId();
hgs
parents: 43
diff changeset
  1547
    NmId msgId = mMessage->envelope().messageId();
hgs
parents: 43
diff changeset
  1548
hgs
parents: 43
diff changeset
  1549
    XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
hgs
parents: 43
diff changeset
  1550
    		msgId, attachmentId);
hgs
parents: 43
diff changeset
  1551
    int error = NmUtilities::openFile(file);
hgs
parents: 43
diff changeset
  1552
    file.close();
hgs
parents: 43
diff changeset
  1553
    if ( error == NmNotFoundError ) {
66
hgs
parents: 62
diff changeset
  1554
        HbMessageBox *box = NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty"));
hgs
parents: 62
diff changeset
  1555
        box->setAttribute(Qt::WA_DeleteOnClose); 
44
hgs
parents: 43
diff changeset
  1556
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1557
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1558
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1559
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1560
   Enables/disables toolbar extension for attach
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1561
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1562
void NmEditorView::enableToolBarAttach(bool enable)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1563
{
43
hgs
parents: 40
diff changeset
  1564
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1565
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1566
    HbToolBar *tb = toolBar();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1567
    if (tb) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1568
        QList<QAction *> toolbarList = tb->actions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1569
        int count = toolbarList.count();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1570
        for (int i = 0; i < count; i++) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1571
            NmAction *action = static_cast<NmAction *>(toolbarList[i]);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1572
            if (action->availabilityCondition() == NmAction::NmAttachable) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1573
                action->setEnabled(enable);
62
hgs
parents: 57
diff changeset
  1574
                if (enable) {
hgs
parents: 57
diff changeset
  1575
                    // For some reason 'Add attachment' toolbar button stays dimmed sometimes,
hgs
parents: 57
diff changeset
  1576
                    // showItems will fix the situation.
hgs
parents: 57
diff changeset
  1577
                    showItems(Hb::ToolBarItem);
hgs
parents: 57
diff changeset
  1578
                }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1579
            }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1580
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1581
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1582
}