emailuis/nmailui/src/nmeditorview.cpp
author hgs
Fri, 23 Jul 2010 19:09:50 +0300
changeset 56 15bc1d5d6267
parent 51 d845db10c0d4
child 57 ae34e1715e21
permissions -rw-r--r--
201029
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";
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
47
hgs
parents: 44
diff changeset
    26
static const QString NmDelimiter("; ");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
	\class NmEditorView
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
	\brief Mail editor view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
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
    Constructor
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
NmEditorView::NmEditorView(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    NmApplication &application,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    NmUiStartParam* startParam,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    NmUiEngine &uiEngine,
43
hgs
parents: 40
diff changeset
    40
    NmAttachmentManager &attaManager,
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    QGraphicsItem *parent)
40
hgs
parents: 23
diff changeset
    42
    : NmBaseView(startParam, application, parent),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    43
      mApplication(application),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    44
      mUiEngine(uiEngine),
43
hgs
parents: 40
diff changeset
    45
      mAttaManager(attaManager),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    46
      mDocumentLoader(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    47
      mHeaderWidget(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    48
      mMessage(NULL),
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
    49
      mContent(NULL),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    50
      mAttachmentListContextMenu(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    51
      mMessageCreationOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    52
      mAddAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    53
      mRemoveAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    54
      mWaitDialog(NULL),
40
hgs
parents: 23
diff changeset
    55
      mQueryDialog(NULL),
hgs
parents: 23
diff changeset
    56
      mAttachmentPicker(NULL),
43
hgs
parents: 40
diff changeset
    57
      mCcBccFieldVisible(false),
56
hgs
parents: 51
diff changeset
    58
      mServiceSendingDialog(NULL),
hgs
parents: 51
diff changeset
    59
      mIsNotFetchedBefore(true)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
{
43
hgs
parents: 40
diff changeset
    61
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    62
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    mDocumentLoader	= new HbDocumentLoader();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    // Set object name
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    setObjectName("NmEditorView");
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    66
    // Set mailbox name to title pane
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    67
    setMailboxName();
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) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   225
        showItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
47
hgs
parents: 44
diff changeset
   226
    }
hgs
parents: 44
diff changeset
   227
    else {
hgs
parents: 44
diff changeset
   228
        hideItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
}
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
    View id
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
NmUiViewId NmEditorView::nmailViewId() const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
{
43
hgs
parents: 40
diff changeset
   237
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   238
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    return NmUiViewMessageEditor;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
/*
40
hgs
parents: 23
diff changeset
   243
   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
   244
*/
40
hgs
parents: 23
diff changeset
   245
void NmEditorView::okToExitView()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
{
43
hgs
parents: 40
diff changeset
   247
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   248
       
hgs
parents: 44
diff changeset
   249
    bool okToExit(true);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   250
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   251
    if (mContent) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   252
        NmEditorHeader *header = mContent->header();
47
hgs
parents: 44
diff changeset
   253
        // show the query if the message has not been sent
hgs
parents: 44
diff changeset
   254
        if (mMessage && header) {
hgs
parents: 44
diff changeset
   255
            // see if editor has any content
hgs
parents: 44
diff changeset
   256
            int subjectLength = 0;
hgs
parents: 44
diff changeset
   257
            if (header->subjectEdit()) {
hgs
parents: 44
diff changeset
   258
                subjectLength = header->subjectEdit()->text().length();
40
hgs
parents: 23
diff changeset
   259
            }
47
hgs
parents: 44
diff changeset
   260
            
hgs
parents: 44
diff changeset
   261
            QList<NmMessagePart*> attachmentList;
hgs
parents: 44
diff changeset
   262
            mMessage->attachmentList(attachmentList);
hgs
parents: 44
diff changeset
   263
            
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   264
            if (mContent->editor()) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   265
                okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty());            
47
hgs
parents: 44
diff changeset
   266
            }
hgs
parents: 44
diff changeset
   267
    
hgs
parents: 44
diff changeset
   268
            // content exists, verify exit from user
hgs
parents: 44
diff changeset
   269
            if (!okToExit) {
hgs
parents: 44
diff changeset
   270
                if (mQueryDialog) {
hgs
parents: 44
diff changeset
   271
                    delete mQueryDialog;
hgs
parents: 44
diff changeset
   272
                    mQueryDialog = 0;
hgs
parents: 44
diff changeset
   273
                }
hgs
parents: 44
diff changeset
   274
                // Launch query dialog.
hgs
parents: 44
diff changeset
   275
                mQueryDialog = 
hgs
parents: 44
diff changeset
   276
                    NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
hgs
parents: 44
diff changeset
   277
                                                                this,
hgs
parents: 44
diff changeset
   278
                                                                SLOT(okToExitQuery(HbAction*)));
hgs
parents: 44
diff changeset
   279
            }
hgs
parents: 44
diff changeset
   280
        }    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
    }
40
hgs
parents: 23
diff changeset
   282
    
hgs
parents: 23
diff changeset
   283
    // no need to query anything, just exit.
hgs
parents: 23
diff changeset
   284
    if(okToExit) {
hgs
parents: 23
diff changeset
   285
        QMetaObject::invokeMethod(&mApplication,
hgs
parents: 23
diff changeset
   286
                                  "popView",
hgs
parents: 23
diff changeset
   287
                                  Qt::QueuedConnection);
hgs
parents: 23
diff changeset
   288
    }
hgs
parents: 23
diff changeset
   289
}
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
40
hgs
parents: 23
diff changeset
   291
/*!
hgs
parents: 23
diff changeset
   292
    Handle the user selection is it ok to exit.
hgs
parents: 23
diff changeset
   293
*/
47
hgs
parents: 44
diff changeset
   294
void NmEditorView::okToExitQuery(HbAction *action)
40
hgs
parents: 23
diff changeset
   295
{
43
hgs
parents: 40
diff changeset
   296
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   297
    
hgs
parents: 40
diff changeset
   298
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   299
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   300
    if (action == dlg->actions().at(0)) {
hgs
parents: 40
diff changeset
   301
        
44
hgs
parents: 43
diff changeset
   302
        // Update draft message with content.
hgs
parents: 43
diff changeset
   303
        updateMessageWithEditorContents();
hgs
parents: 43
diff changeset
   304
43
hgs
parents: 40
diff changeset
   305
        // Save message to drafts
hgs
parents: 40
diff changeset
   306
        QList<NmOperation *> preliminaryOperations;
hgs
parents: 40
diff changeset
   307
        if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   308
            preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 40
diff changeset
   309
        }
hgs
parents: 40
diff changeset
   310
        if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   311
            preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 40
diff changeset
   312
        }
hgs
parents: 40
diff changeset
   313
        // ownership of mMessage is transferred
hgs
parents: 40
diff changeset
   314
        // NmOperations are automatically deleted after completion
hgs
parents: 40
diff changeset
   315
        mUiEngine.saveDraftMessage(mMessage, preliminaryOperations);
hgs
parents: 40
diff changeset
   316
        mMessage = NULL;
hgs
parents: 40
diff changeset
   317
        preliminaryOperations.clear();
hgs
parents: 40
diff changeset
   318
    }    
hgs
parents: 40
diff changeset
   319
    
hgs
parents: 40
diff changeset
   320
    // Close the view
hgs
parents: 40
diff changeset
   321
    QMetaObject::invokeMethod(&mApplication,
hgs
parents: 40
diff changeset
   322
                              "popView",
hgs
parents: 40
diff changeset
   323
                              Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    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
   328
    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
   329
    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
   330
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
void NmEditorView::aboutToExitView()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
{
43
hgs
parents: 40
diff changeset
   333
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   334
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
    // 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
   336
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   337
        mAddAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   338
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   339
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   340
        mRemoveAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   341
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
44
hgs
parents: 43
diff changeset
   343
    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
   344
        // Delete message from drafts
43
hgs
parents: 40
diff changeset
   345
        mUiEngine.removeDraftMessage(mMessage);
hgs
parents: 40
diff changeset
   346
        mMessage = NULL;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   351
    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
   352
*/
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   353
void NmEditorView::viewReady()
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   354
{
43
hgs
parents: 40
diff changeset
   355
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   356
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   357
    // 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
   358
    // 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
   359
    connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu()));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   360
    NmAction *dummy = new NmAction(0);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   361
    menu()->addAction(dummy);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   362
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   363
    mVkbHost = new HbShrinkingVkbHost(this);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   364
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   365
    initializeVKB();
47
hgs
parents: 44
diff changeset
   366
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   367
    //start to listen VKB open and close signals for hiding the chrome.
47
hgs
parents: 44
diff changeset
   368
    connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
hgs
parents: 44
diff changeset
   369
    connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   370
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   371
    connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   372
            this, SLOT(setButtonsDimming(bool)) );
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   373
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   374
    // Connect to observe orientation change events
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   375
    connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   376
            this, SLOT(orientationChanged(Qt::Orientation)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   377
    // Signal for handling the attachment list selection
44
hgs
parents: 43
diff changeset
   378
    connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)),
hgs
parents: 43
diff changeset
   379
            this, SLOT(openAttachmentTriggered(NmId)));
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   380
    connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   381
            this, SLOT(attachmentLongPressed(NmId, QPointF)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   382
    
44
hgs
parents: 43
diff changeset
   383
    if (mStartParam) {
hgs
parents: 43
diff changeset
   384
        fetchMessageIfNeeded(*mStartParam);
hgs
parents: 43
diff changeset
   385
    }
hgs
parents: 43
diff changeset
   386
    else { // execution cannot proceed without start param 
hgs
parents: 43
diff changeset
   387
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 43
diff changeset
   388
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   389
}
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   390
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   391
/*!
43
hgs
parents: 40
diff changeset
   392
    If entering editor for forwarding or replying, use attachment manager
hgs
parents: 40
diff changeset
   393
    to check that we have all message parts fetched. Also show dialog for
hgs
parents: 40
diff changeset
   394
    fetching progress.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   395
*/
44
hgs
parents: 43
diff changeset
   396
void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
{
43
hgs
parents: 40
diff changeset
   398
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
    
56
hgs
parents: 51
diff changeset
   400
    if (mIsNotFetchedBefore == true) {
hgs
parents: 51
diff changeset
   401
        if (startParam.editorStartMode() == NmUiEditorForward
hgs
parents: 51
diff changeset
   402
            || startParam.editorStartMode()== NmUiEditorReply
hgs
parents: 51
diff changeset
   403
            || startParam.editorStartMode() == NmUiEditorReplyAll) {
43
hgs
parents: 40
diff changeset
   404
        
56
hgs
parents: 51
diff changeset
   405
            fetchProgressDialogShow();
hgs
parents: 51
diff changeset
   406
            mAttaManager.clearObserver();
hgs
parents: 51
diff changeset
   407
            mAttaManager.setObserver(this);
hgs
parents: 51
diff changeset
   408
            mAttaManager.fetchAllMessageParts(
hgs
parents: 51
diff changeset
   409
                startParam.mailboxId(),
hgs
parents: 51
diff changeset
   410
                startParam.folderId(),
hgs
parents: 51
diff changeset
   411
                startParam.messageId());
hgs
parents: 51
diff changeset
   412
			mIsNotFetchedBefore = false;
hgs
parents: 51
diff changeset
   413
        }
hgs
parents: 51
diff changeset
   414
        else {
hgs
parents: 51
diff changeset
   415
            startMessageCreation(startParam);
hgs
parents: 51
diff changeset
   416
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
/*!
43
hgs
parents: 40
diff changeset
   421
    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
   422
*/
43
hgs
parents: 40
diff changeset
   423
void NmEditorView::progressChanged(int value)
hgs
parents: 40
diff changeset
   424
{
hgs
parents: 40
diff changeset
   425
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   426
    
hgs
parents: 40
diff changeset
   427
    Q_UNUSED(value);
hgs
parents: 40
diff changeset
   428
}
hgs
parents: 40
diff changeset
   429
hgs
parents: 40
diff changeset
   430
/*!
hgs
parents: 40
diff changeset
   431
    Slot. Called when attachments fetch is completed. We can start
hgs
parents: 40
diff changeset
   432
    message creation. 
hgs
parents: 40
diff changeset
   433
*/
hgs
parents: 40
diff changeset
   434
void NmEditorView::fetchCompleted(int result)
hgs
parents: 40
diff changeset
   435
{
hgs
parents: 40
diff changeset
   436
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   437
    
44
hgs
parents: 43
diff changeset
   438
    if (result == NmNoError && mStartParam) {
hgs
parents: 43
diff changeset
   439
        startMessageCreation(*mStartParam);
43
hgs
parents: 40
diff changeset
   440
    }
hgs
parents: 40
diff changeset
   441
    else {
47
hgs
parents: 44
diff changeset
   442
        // Show the fetching failed note only when
hgs
parents: 44
diff changeset
   443
        // the error is not Device/System errors, 
hgs
parents: 44
diff changeset
   444
        if (result != NmNoError && 
hgs
parents: 44
diff changeset
   445
            result != NmNotFoundError &&
hgs
parents: 44
diff changeset
   446
            result != NmGeneralError &&
hgs
parents: 44
diff changeset
   447
            result != NmCancelError &&
hgs
parents: 44
diff changeset
   448
            result != NmAuthenticationError &&
hgs
parents: 44
diff changeset
   449
            result != NmServerConnectionError &&
hgs
parents: 44
diff changeset
   450
            result != NmConnectionError) {
hgs
parents: 44
diff changeset
   451
            
hgs
parents: 44
diff changeset
   452
            HbNotificationDialog *note = new HbNotificationDialog(); 
hgs
parents: 44
diff changeset
   453
            
hgs
parents: 44
diff changeset
   454
            bool enalbeAttribute(true);
hgs
parents: 44
diff changeset
   455
            note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute);
hgs
parents: 44
diff changeset
   456
            
hgs
parents: 44
diff changeset
   457
            note->setIcon(HbIcon(QLatin1String("note_warning")));
hgs
parents: 44
diff changeset
   458
            
hgs
parents: 44
diff changeset
   459
            note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed"));
hgs
parents: 44
diff changeset
   460
            note->setTitleTextWrapping(Hb::TextWordWrap);
hgs
parents: 44
diff changeset
   461
            
hgs
parents: 44
diff changeset
   462
            note->setDismissPolicy(HbNotificationDialog::TapAnywhere);
hgs
parents: 44
diff changeset
   463
            note->setTimeout(HbNotificationDialog::StandardTimeout);
hgs
parents: 44
diff changeset
   464
            
hgs
parents: 44
diff changeset
   465
            note->setSequentialShow(true);
hgs
parents: 44
diff changeset
   466
            note->show();
hgs
parents: 44
diff changeset
   467
        }
44
hgs
parents: 43
diff changeset
   468
        
47
hgs
parents: 44
diff changeset
   469
        mWaitDialog->close();         
43
hgs
parents: 40
diff changeset
   470
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   471
    }
hgs
parents: 40
diff changeset
   472
}
hgs
parents: 40
diff changeset
   473
hgs
parents: 40
diff changeset
   474
void NmEditorView::fetchProgressDialogShow()
hgs
parents: 40
diff changeset
   475
{
hgs
parents: 40
diff changeset
   476
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   477
    
hgs
parents: 40
diff changeset
   478
    delete mWaitDialog;
hgs
parents: 40
diff changeset
   479
    mWaitDialog = NULL;
hgs
parents: 40
diff changeset
   480
    // Create new wait dialog and set it to me modal with dimmed background
hgs
parents: 40
diff changeset
   481
    mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   482
    mWaitDialog->setModal(true);
hgs
parents: 40
diff changeset
   483
    mWaitDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   484
    connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(fetchProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   485
    mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
hgs
parents: 40
diff changeset
   486
    // Display wait dialog
hgs
parents: 40
diff changeset
   487
    mWaitDialog->show();
hgs
parents: 40
diff changeset
   488
}
hgs
parents: 40
diff changeset
   489
hgs
parents: 40
diff changeset
   490
/*!
hgs
parents: 40
diff changeset
   491
    This is called by mFetchProgressDialog when the note is cancelled
hgs
parents: 40
diff changeset
   492
 */
hgs
parents: 40
diff changeset
   493
void NmEditorView::fetchProgressDialogCancelled()
hgs
parents: 40
diff changeset
   494
{
hgs
parents: 40
diff changeset
   495
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   496
    
hgs
parents: 40
diff changeset
   497
    if (mAttaManager.isFetching()) {
hgs
parents: 40
diff changeset
   498
        mAttaManager.cancelFetch();
hgs
parents: 40
diff changeset
   499
        mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
   500
    }
hgs
parents: 40
diff changeset
   501
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   502
}
hgs
parents: 40
diff changeset
   503
44
hgs
parents: 43
diff changeset
   504
void NmEditorView::startMessageCreation(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
{
43
hgs
parents: 40
diff changeset
   506
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   507
    
44
hgs
parents: 43
diff changeset
   508
    NmUiEditorStartMode startMode = startParam.editorStartMode();
hgs
parents: 43
diff changeset
   509
    NmId mailboxId = startParam.mailboxId();
hgs
parents: 43
diff changeset
   510
    NmId folderId = startParam.folderId();
hgs
parents: 43
diff changeset
   511
    NmId msgId = startParam.messageId();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   513
    if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   514
        mMessageCreationOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   515
    }
47
hgs
parents: 44
diff changeset
   516
	  
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   517
    // 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
   518
    if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
        mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
        mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
            msgId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
            startMode == NmUiEditorReplyAll);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    }
44
hgs
parents: 43
diff changeset
   526
    else if (startMode == NmUiEditorFromDrafts) {
hgs
parents: 43
diff changeset
   527
        // Draft opened, so reload message and fill editor with message data.
hgs
parents: 43
diff changeset
   528
        mMessage = mUiEngine.message(
hgs
parents: 43
diff changeset
   529
            mStartParam->mailboxId(), 
hgs
parents: 43
diff changeset
   530
            mStartParam->folderId(), 
hgs
parents: 43
diff changeset
   531
            mStartParam->messageId());
hgs
parents: 43
diff changeset
   532
        fillEditorWithMessageContents();
hgs
parents: 43
diff changeset
   533
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
        mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
    // operation continues in messageCreated() once it finishes ok
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
    if (mMessageCreationOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
        connect(mMessageCreationOperation,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
                SIGNAL(operationCompleted(int)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
                this,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
                SLOT(messageCreated(int)));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
    }    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    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
   549
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
void NmEditorView::startSending()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
{
43
hgs
parents: 40
diff changeset
   552
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   553
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
    // The message contents should be verified
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    updateMessageWithEditorContents();
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
    // verify addresses before sending
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
    QList<NmAddress> invalidAddresses;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   559
    if (mMessage) {
47
hgs
parents: 44
diff changeset
   560
        NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress);
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
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
    if (invalidAddresses.count() > 0) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
        // invalid addresses found, verify send from user
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
        QString noteText = hbTrId("txt_mail_dialog_invalid_mail_address_send");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
        // set the first failing address to the note
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
        noteText = noteText.arg(invalidAddresses.at(0).address());
40
hgs
parents: 23
diff changeset
   569
        
hgs
parents: 23
diff changeset
   570
        if (mQueryDialog) {
hgs
parents: 23
diff changeset
   571
            delete mQueryDialog;
hgs
parents: 23
diff changeset
   572
            mQueryDialog = 0;
hgs
parents: 23
diff changeset
   573
        }
hgs
parents: 23
diff changeset
   574
        // Launch query dialog. Pressing "yes" will finalize the sending.
hgs
parents: 23
diff changeset
   575
        mQueryDialog = NmUtilities::displayQuestionNote(noteText,
hgs
parents: 23
diff changeset
   576
                                                        this,
hgs
parents: 23
diff changeset
   577
                                                        SLOT(invalidAddressQuery(HbAction*)));
hgs
parents: 23
diff changeset
   578
    }
hgs
parents: 23
diff changeset
   579
    else {
hgs
parents: 23
diff changeset
   580
        // no need to ask anything, just send
hgs
parents: 23
diff changeset
   581
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
    }
40
hgs
parents: 23
diff changeset
   583
}
hgs
parents: 23
diff changeset
   584
hgs
parents: 23
diff changeset
   585
/*!
hgs
parents: 23
diff changeset
   586
    Send the message after all checks have been done.
hgs
parents: 23
diff changeset
   587
*/
hgs
parents: 23
diff changeset
   588
void NmEditorView::finalizeSending()
hgs
parents: 23
diff changeset
   589
{
43
hgs
parents: 40
diff changeset
   590
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   591
    
40
hgs
parents: 23
diff changeset
   592
    QList<NmOperation *> preliminaryOperations;
43
hgs
parents: 40
diff changeset
   593
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   594
        preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 40
diff changeset
   595
    }
hgs
parents: 40
diff changeset
   596
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   597
        preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 40
diff changeset
   598
    }
40
hgs
parents: 23
diff changeset
   599
    // ownership of mMessage is transferred
hgs
parents: 23
diff changeset
   600
    // NmOperations are automatically deleted after completion
hgs
parents: 23
diff changeset
   601
    mUiEngine.sendMessage(mMessage, preliminaryOperations);
hgs
parents: 23
diff changeset
   602
    mMessage = NULL;
hgs
parents: 23
diff changeset
   603
    preliminaryOperations.clear();
43
hgs
parents: 40
diff changeset
   604
hgs
parents: 40
diff changeset
   605
    bool service = XQServiceUtil::isService();
hgs
parents: 40
diff changeset
   606
hgs
parents: 40
diff changeset
   607
    // If sending is started as a service, progress dialog needs to be shown
hgs
parents: 40
diff changeset
   608
    // so long that sending is finished otherwise we can close pop current view.
44
hgs
parents: 43
diff changeset
   609
    if (service && mStartParam && mStartParam->service() && 
hgs
parents: 43
diff changeset
   610
        mUiEngine.isSendingMessage()) {
43
hgs
parents: 40
diff changeset
   611
        connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
hgs
parents: 40
diff changeset
   612
            this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
hgs
parents: 40
diff changeset
   613
hgs
parents: 40
diff changeset
   614
        // Construct and setup the wait dialog.
hgs
parents: 40
diff changeset
   615
        mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   616
        mServiceSendingDialog->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 40
diff changeset
   617
        mServiceSendingDialog->setText(hbTrId("txt_mail_shareui_sending_please_wait"));
hgs
parents: 40
diff changeset
   618
        connect(mServiceSendingDialog, SIGNAL(cancelled()),
hgs
parents: 40
diff changeset
   619
            this, SLOT(sendProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   620
hgs
parents: 40
diff changeset
   621
        if (!XQServiceUtil::isEmbedded()) {
hgs
parents: 40
diff changeset
   622
            // Hide the application.
hgs
parents: 40
diff changeset
   623
            XQServiceUtil::toBackground(true);
hgs
parents: 40
diff changeset
   624
        }
hgs
parents: 40
diff changeset
   625
         // Display the wait dialog.
hgs
parents: 40
diff changeset
   626
         mServiceSendingDialog->setModal(true);
hgs
parents: 40
diff changeset
   627
         mServiceSendingDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   628
         mServiceSendingDialog->show();
hgs
parents: 40
diff changeset
   629
    } else {
hgs
parents: 40
diff changeset
   630
        // Must use delayed editor view destruction so that query dialog
hgs
parents: 40
diff changeset
   631
        // (which has signaled this) gets time to complete.
hgs
parents: 40
diff changeset
   632
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   633
    }
40
hgs
parents: 23
diff changeset
   634
}
hgs
parents: 23
diff changeset
   635
hgs
parents: 23
diff changeset
   636
/*!
hgs
parents: 23
diff changeset
   637
    Handle the user selection for invalid address query which was started by startSending.
hgs
parents: 23
diff changeset
   638
*/
hgs
parents: 23
diff changeset
   639
void NmEditorView::invalidAddressQuery(HbAction* action)
hgs
parents: 23
diff changeset
   640
{
43
hgs
parents: 40
diff changeset
   641
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   642
hgs
parents: 40
diff changeset
   643
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   644
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   645
    if (action == dlg->actions().at(0)) {
40
hgs
parents: 23
diff changeset
   646
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
/*!
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   651
    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
   652
*/
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   653
void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event)
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   654
{
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   655
    NM_FUNCTION;
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   656
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   657
    NmBaseView::resizeEvent(event);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   658
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   659
    emit sizeChanged();
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   660
}
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   661
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   662
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
    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
   664
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
void NmEditorView::messageCreated(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
{
43
hgs
parents: 40
diff changeset
   667
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   668
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    delete mMessage;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
    mMessage = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
43
hgs
parents: 40
diff changeset
   672
    // Close wait dialog here
hgs
parents: 40
diff changeset
   673
    if (mWaitDialog) {
hgs
parents: 40
diff changeset
   674
        mWaitDialog->close();
hgs
parents: 40
diff changeset
   675
    }
hgs
parents: 40
diff changeset
   676
    
44
hgs
parents: 43
diff changeset
   677
    if (result == NmNoError && mStartParam && mMessageCreationOperation) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
        NmUiEditorStartMode startMode = mStartParam->editorStartMode();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
        // 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
   681
        mMessage = mUiEngine.message(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
            mStartParam->mailboxId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
            mStartParam->folderId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
            mMessageCreationOperation->getMessageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
        fillEditorWithMessageContents();       
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
   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
   692
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
void NmEditorView::updateMessageWithEditorContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
{
43
hgs
parents: 40
diff changeset
   695
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   696
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
    if (mMessage) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   698
        if (mContent && mContent->editor()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
            NmMessagePart* bodyPart = mMessage->htmlBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   701
                bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml);
18
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
            bodyPart = mMessage->plainTextBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   705
                bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
        }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   708
        if (mContent && mContent->header() ) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   709
            if (mContent->header()->subjectEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
                mMessage->envelope().setSubject(
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   711
                    mContent->header()->subjectEdit()->text());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   713
            if (mContent->header()->toEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
                QString toFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   715
                    mContent->header()->toEdit()->text();
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
                // 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
   718
                // after list of addresses
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
                if (toFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   720
                    mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   723
            if (mContent->header()->ccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
                QString ccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   725
                    mContent->header()->ccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
                if (ccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   728
                    mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList());      
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   731
            if (mContent->header()->bccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
                QString bccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   733
                    mContent->header()->bccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
                if (bccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   736
                    mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
        }
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
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
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
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
    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
   746
    editor is launched.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   747
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
void NmEditorView::fillEditorWithMessageContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
{
43
hgs
parents: 40
diff changeset
   750
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   751
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   752
    if (!mStartParam || !mMessage || !mContent) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
        return;
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
    NmMessageEnvelope messageEnvelope(mMessage->envelope());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
    bool useStartParam(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
44
hgs
parents: 43
diff changeset
   759
    NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
44
hgs
parents: 43
diff changeset
   761
    if (editorStartMode == NmUiEditorMailto) {
hgs
parents: 43
diff changeset
   762
        // Retrieve the message header data e.g. recipients from mStartParam.
hgs
parents: 43
diff changeset
   763
        useStartParam = true;        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
    // Set recipients (to, cc and bcc).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
    QString toAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    QString ccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
    QString bccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
        toAddressesString = addressListToString(mStartParam->mailtoAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
        ccAddressesString = addressListToString(mStartParam->ccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
        bccAddressesString = addressListToString(mStartParam->bccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
        toAddressesString = addressListToString(messageEnvelope.toRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
        ccAddressesString = addressListToString(messageEnvelope.ccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
        bccAddressesString = addressListToString(messageEnvelope.bccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   782
    mContent->header()->toEdit()->setPlainText(toAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   783
    mContent->header()->ccEdit()->setPlainText(ccAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   784
    mContent->header()->bccEdit()->setPlainText(bccAddressesString);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    if (ccAddressesString.length() || bccAddressesString.length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
        // 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
   788
        // the addresses by expanding the group box.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   789
        mContent->header()->setFieldVisibility(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    // Set subject.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
        QString *subject = mStartParam->subject();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
        if (subject) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   797
            mContent->header()->subjectEdit()->setPlainText(*subject);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
        }
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
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
        // Construct the subject field.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   802
        mContent->header()->subjectEdit()->setPlainText(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
            addSubjectPrefix(editorStartMode, messageEnvelope.subject()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
    }
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
    // Set priority.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   807
    if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   808
        //Clear the importance flag. Replied messages dont keep the importance
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   809
        setPriority(NmActionResponseCommandNone);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   810
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
    mHeaderWidget->setPriority(messageEnvelope.priority());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
    // Set the message body.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   814
    if (editorStartMode==NmUiEditorReply||
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   815
        editorStartMode==NmUiEditorReplyAll||
44
hgs
parents: 43
diff changeset
   816
        editorStartMode==NmUiEditorForward||
hgs
parents: 43
diff changeset
   817
        editorStartMode==NmUiEditorFromDrafts){
43
hgs
parents: 40
diff changeset
   818
hgs
parents: 40
diff changeset
   819
        // Use the body from the original message.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   820
        NmMessage *originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   821
                                                       mStartParam->folderId(), 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   822
                                                       mStartParam->messageId());
43
hgs
parents: 40
diff changeset
   823
hgs
parents: 40
diff changeset
   824
        if (originalMessage) {
hgs
parents: 40
diff changeset
   825
            NmMessagePart *plainPart = originalMessage->plainTextBodyPart();
hgs
parents: 40
diff changeset
   826
hgs
parents: 40
diff changeset
   827
            if (plainPart) {
hgs
parents: 40
diff changeset
   828
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   829
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   830
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   831
                                               *plainPart);
hgs
parents: 40
diff changeset
   832
            }
hgs
parents: 40
diff changeset
   833
hgs
parents: 40
diff changeset
   834
            NmMessagePart *htmlPart = originalMessage->htmlBodyPart();
hgs
parents: 40
diff changeset
   835
hgs
parents: 40
diff changeset
   836
            if (htmlPart) {
hgs
parents: 40
diff changeset
   837
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   838
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   839
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   840
                                               *htmlPart);
hgs
parents: 40
diff changeset
   841
            }
hgs
parents: 40
diff changeset
   842
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   843
		mContent->setMessageData(*originalMessage, editorStartMode);
43
hgs
parents: 40
diff changeset
   844
        }
hgs
parents: 40
diff changeset
   845
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   846
        delete originalMessage;
43
hgs
parents: 40
diff changeset
   847
        originalMessage = NULL;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   848
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
    // 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
   851
    QList<NmMessagePart*> attachments;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
    mMessage->attachmentList(attachments);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
    for (int i=0; i<attachments.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
        mHeaderWidget->addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
            attachments[i]->attachmentName(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
            QString::number(attachments[i]->size()),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   858
            attachments[i]->partId());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
44
hgs
parents: 43
diff changeset
   861
    // Attach passed files to the message.
hgs
parents: 43
diff changeset
   862
    QStringList *fileList = mStartParam->attachmentList();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
44
hgs
parents: 43
diff changeset
   864
    if (fileList) {
hgs
parents: 43
diff changeset
   865
        addAttachments(*fileList);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    createToolBar. Function asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
    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
   874
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
void NmEditorView::createToolBar()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
{
43
hgs
parents: 40
diff changeset
   877
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   878
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
    if (tb && &extMngr && mStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
        tb->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
        NmActionRequest request(this, NmActionToolbar, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
                NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
            tb->addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
            // 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
   890
            // 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
   891
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
            }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   894
            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
   895
                HbToolBarExtension* extension = new HbToolBarExtension();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   896
                mAttachmentPicker = new NmAttachmentPicker(this);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   897
                
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   898
                if (extension && mAttachmentPicker) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   899
                    connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   900
                        this, SLOT(onAttachmentReqCompleted(const QVariant &)));            
56
hgs
parents: 51
diff changeset
   901
                    
hgs
parents: 51
diff changeset
   902
                    list[i]->setToolBarExtension(extension);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   903
                    
56
hgs
parents: 51
diff changeset
   904
                    //content widget to get the items to a list
hgs
parents: 51
diff changeset
   905
                    mTBExtnContentWidget = new HbListWidget();
hgs
parents: 51
diff changeset
   906
                    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
43
hgs
parents: 40
diff changeset
   907
                    
56
hgs
parents: 51
diff changeset
   908
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo"));
hgs
parents: 51
diff changeset
   909
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_music"));
hgs
parents: 51
diff changeset
   910
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video"));
hgs
parents: 51
diff changeset
   911
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other"));
hgs
parents: 51
diff changeset
   912
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo"));
hgs
parents: 51
diff changeset
   913
                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video"));
hgs
parents: 51
diff changeset
   914
                    HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype();
hgs
parents: 51
diff changeset
   915
                    HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces);
hgs
parents: 51
diff changeset
   916
                    listView->setDefaultFrame(frame);
43
hgs
parents: 40
diff changeset
   917
                    
56
hgs
parents: 51
diff changeset
   918
                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), 
hgs
parents: 51
diff changeset
   919
                    		mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*)));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   920
            
56
hgs
parents: 51
diff changeset
   921
                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
hgs
parents: 51
diff changeset
   922
                            extension, SLOT(close()));
43
hgs
parents: 40
diff changeset
   923
                                        
56
hgs
parents: 51
diff changeset
   924
                    extension->setContentWidget(mTBExtnContentWidget);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   925
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   926
            }            
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   927
        }        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
    createOptionsMenu. Functions asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
    to be added to options menu.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
void NmEditorView::createOptionsMenu()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
{
43
hgs
parents: 40
diff changeset
   937
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   938
    
40
hgs
parents: 23
diff changeset
   939
    menu()->clearActions();
hgs
parents: 23
diff changeset
   940
hgs
parents: 23
diff changeset
   941
	// Create CC/BCC options menu object
hgs
parents: 23
diff changeset
   942
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
   943
        menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   944
    }
hgs
parents: 23
diff changeset
   945
    else {
hgs
parents: 23
diff changeset
   946
        menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   947
    }
hgs
parents: 23
diff changeset
   948
hgs
parents: 23
diff changeset
   949
	// Create Priority options menu object
hgs
parents: 23
diff changeset
   950
	if (!mPrioritySubMenu) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
        mPrioritySubMenu = new HbMenu();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
    mPrioritySubMenu->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
    NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
            NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
            mStartParam->messageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
    QList<NmAction*> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
    extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
    for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
        mPrioritySubMenu->addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
    mPrioritySubMenu->setObjectName("editorPrioritySubMenu");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
    mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority"));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
    menu()->addMenu(mPrioritySubMenu);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
/*!
40
hgs
parents: 23
diff changeset
   969
    Show or hide Cc field
hgs
parents: 23
diff changeset
   970
*/
hgs
parents: 23
diff changeset
   971
void NmEditorView::switchCcBccFieldVisibility()
hgs
parents: 23
diff changeset
   972
{
43
hgs
parents: 40
diff changeset
   973
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   974
    
40
hgs
parents: 23
diff changeset
   975
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
   976
    	mCcBccFieldVisible = false;
hgs
parents: 23
diff changeset
   977
    }
hgs
parents: 23
diff changeset
   978
    else {
hgs
parents: 23
diff changeset
   979
    	mCcBccFieldVisible = true;
hgs
parents: 23
diff changeset
   980
    }
hgs
parents: 23
diff changeset
   981
    mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
hgs
parents: 23
diff changeset
   982
}
hgs
parents: 23
diff changeset
   983
hgs
parents: 23
diff changeset
   984
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
    handleActionCommand. From NmActionObserver, extension manager calls this
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
    call to handle menu command in the UI.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
void NmEditorView::handleActionCommand(NmActionResponse &actionResponse)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
{
43
hgs
parents: 40
diff changeset
   990
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   991
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
    NmActionResponseCommand responseCommand = actionResponse.responseCommand();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
    // Handle options menu
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
    if (actionResponse.menuType() == NmActionOptionsMenu) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
        setPriority(responseCommand);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   997
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   998
    else if (actionResponse.menuType() == NmActionToolbar) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
        switch (responseCommand) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1000
        case NmActionResponseCommandSendMail: {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1001
            // 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
  1002
            // outobox checking
43
hgs
parents: 40
diff changeset
  1003
            if (!mMessageCreationOperation || !mMessageCreationOperation->isRunning()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
                startSending();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
            }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1006
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1007
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1008
        default:
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1009
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1010
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1011
    }
40
hgs
parents: 23
diff changeset
  1012
    else if (actionResponse.menuType() == NmActionContextMenu) {
hgs
parents: 23
diff changeset
  1013
        switch (responseCommand) {
hgs
parents: 23
diff changeset
  1014
        case NmActionResponseCommandRemoveAttachment: {
hgs
parents: 23
diff changeset
  1015
            removeAttachmentTriggered();
hgs
parents: 23
diff changeset
  1016
            break;
hgs
parents: 23
diff changeset
  1017
        }
hgs
parents: 23
diff changeset
  1018
        case NmActionResponseCommandOpenAttachment: {
44
hgs
parents: 43
diff changeset
  1019
            openAttachmentTriggered(mSelectedAttachment);
40
hgs
parents: 23
diff changeset
  1020
            break;
hgs
parents: 23
diff changeset
  1021
        }
hgs
parents: 23
diff changeset
  1022
        default:
hgs
parents: 23
diff changeset
  1023
            break;
hgs
parents: 23
diff changeset
  1024
        }
hgs
parents: 23
diff changeset
  1025
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1028
/*!
43
hgs
parents: 40
diff changeset
  1029
    Slot. Cancelled sending progress dialog.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1030
*/
43
hgs
parents: 40
diff changeset
  1031
void NmEditorView::sendProgressDialogCancelled()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
{
43
hgs
parents: 40
diff changeset
  1033
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1034
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1035
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1039
   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
  1040
   availability condition NmSendable set, will be enabled/disabled.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1041
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1042
void NmEditorView::setButtonsDimming(bool enabled)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1043
{
43
hgs
parents: 40
diff changeset
  1044
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1045
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
    // Set the toolbar action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
    if (tb) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
        QList<QAction *> toolbarList = tb->actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
        int count = toolbarList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1052
            NmAction *action = static_cast<NmAction *>(toolbarList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
                action->setEnabled(enabled);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1055
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1058
        // Set the VKB action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
        // 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
  1060
        // this only to one of them.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1061
        HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1062
        QList<HbAction *> vkbList = editorInterface.actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
        count = vkbList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
            NmAction *action = static_cast<NmAction *>(vkbList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1066
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1067
                action->setEnabled(enabled);
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
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
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
    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
  1075
    for all editors of the view.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
void NmEditorView::initializeVKB()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
{
43
hgs
parents: 40
diff changeset
  1079
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1080
    
44
hgs
parents: 43
diff changeset
  1081
    if (!mStartParam) {
hgs
parents: 43
diff changeset
  1082
        return;
hgs
parents: 43
diff changeset
  1083
    }
hgs
parents: 43
diff changeset
  1084
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
    NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
         NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
    if (&extMngr) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
        // 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
  1093
        // 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
  1094
        // 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
  1095
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
            list[i]->setIcon(NmIcons::getIcon(NmIcons::NmIconSend));
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
            // 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
  1102
            // editors that show the button in VKB.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1103
            HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
            editorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1105
            HbEditorInterface toEditorInterface(mContent->header()->toEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1106
            toEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1107
            HbEditorInterface ccEditorInterface(mContent->header()->ccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
            ccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1109
            HbEditorInterface bccEditorInterface(mContent->header()->bccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
            bccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1111
            HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
            subjectEditorInterface.addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1113
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1114
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1115
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1116
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1117
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
    Set mailbox name to title
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
void NmEditorView::setMailboxName()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
{
43
hgs
parents: 40
diff changeset
  1122
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1123
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
    if (mStartParam){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
        NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
        if (meta){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
            setTitle(meta->name());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
    }
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
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
   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
  1134
   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
  1135
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject )
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
{
43
hgs
parents: 40
diff changeset
  1138
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1139
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1140
    QString newSubject(subject.trimmed());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
    if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
        startMode == NmUiEditorForward) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1144
        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
  1145
        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
  1146
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
        // strip extra prefixes from beginning
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
        int rePrefixLength(rePrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
        int fwPrefixLength(fwPrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
        bool startswithRe(newSubject.startsWith(rePrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
        bool startswithFw(newSubject.startsWith(fwPrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
        while (startswithRe || startswithFw) {            
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
            if (startswithRe) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
                newSubject.remove(0,rePrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
                newSubject = newSubject.trimmed();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
            else if (startswithFw) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
                newSubject.remove(0,fwPrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
                newSubject = newSubject.trimmed();
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
            startswithRe = newSubject.startsWith(rePrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
            startswithFw = newSubject.startsWith(fwPrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
        if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
            newSubject = rePrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1170
        else if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1171
            newSubject = fwPrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
        }
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
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
    return newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
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
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
    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
  1181
    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
  1182
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1183
void NmEditorView::onAttachmentReqCompleted(const QVariant &value)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
{
43
hgs
parents: 40
diff changeset
  1185
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1186
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1187
    //temporary fix for music picker back button:
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1188
    //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
  1189
	if (value.canConvert<QStringList>()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1190
	    QStringList list = value.toStringList();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1191
        if (!list.at(0).isEmpty()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1192
            addAttachments(list);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1193
        }
18
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
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
43
hgs
parents: 40
diff changeset
  1197
/*!
hgs
parents: 40
diff changeset
  1198
    This slot is called when 'attachment picker' request has been unsuccesfull
hgs
parents: 40
diff changeset
  1199
    Parameter 'errorCode' is the error code returned by the service
hgs
parents: 40
diff changeset
  1200
    Parameter 'errorMessage' is the error message returned by the service
hgs
parents: 40
diff changeset
  1201
*/
hgs
parents: 40
diff changeset
  1202
void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
hgs
parents: 40
diff changeset
  1203
{
hgs
parents: 40
diff changeset
  1204
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1205
    Q_UNUSED(errorCode);
hgs
parents: 43
diff changeset
  1206
    Q_UNUSED(errorMessage);
43
hgs
parents: 40
diff changeset
  1207
    NM_COMMENT(QString("Error code: %1").arg(errorCode));
hgs
parents: 40
diff changeset
  1208
    NM_COMMENT(QString("Error message: %1").arg(errorMessage));
hgs
parents: 40
diff changeset
  1209
}
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1210
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1211
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1212
    Closes the wait dialog if one exists.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1213
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1214
    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
  1215
    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
  1216
    may cause unwanted cancelling of the operation.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1217
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1218
void NmEditorView::handleSendOperationCompleted()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1219
{
43
hgs
parents: 40
diff changeset
  1220
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1221
hgs
parents: 40
diff changeset
  1222
    if (mServiceSendingDialog) {
hgs
parents: 40
diff changeset
  1223
        mServiceSendingDialog->close();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1224
    }
43
hgs
parents: 40
diff changeset
  1225
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1226
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1227
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1228
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1229
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1230
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1231
    Add list of attachments
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
void NmEditorView::addAttachments(const QStringList& fileNames) 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
{
43
hgs
parents: 40
diff changeset
  1235
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1236
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1237
    // Add attachment name into UI
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1238
    foreach (QString fileName, fileNames)  {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1239
        // 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
  1240
        mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0));
43
hgs
parents: 40
diff changeset
  1241
        NM_COMMENT(fileName);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1242
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1243
    //  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
  1244
    if (mAddAttachmentOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1245
        if (!mAddAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1246
            mAddAttachmentOperation->cancelOperation();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1247
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1248
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1249
    // 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
  1250
    // 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
  1251
    mAddAttachmentOperation = mUiEngine.addAttachments(*mMessage, fileNames);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1252
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1253
    if (mAddAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1254
        enableToolBarAttach(false);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1255
        // Signal to inform completion of one attachment
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1256
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1257
                SIGNAL(operationPartCompleted(const QString &, const NmId &, int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1258
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1259
                SLOT(oneAttachmentAdded(const QString &, const NmId &, int)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1260
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1261
        // 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
  1262
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1263
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1264
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1265
                SLOT(allAttachmentsAdded(int)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1268
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1270
    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
  1271
    from UI by longpress.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
*/
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1273
void NmEditorView::attachmentLongPressed(NmId attachmentPartId, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
{
43
hgs
parents: 40
diff changeset
  1275
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1276
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1277
    // 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
  1278
    // 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
  1279
    mSelectedAttachment = attachmentPartId;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1280
	
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1281
    if (!mAttachmentListContextMenu) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1282
        mAttachmentListContextMenu = new HbMenu();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1283
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1284
    mAttachmentListContextMenu->clearActions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1285
    NmActionRequest request(this, NmActionContextMenu, NmActionContextViewEditor,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1286
        NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1287
        mStartParam->messageId());
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1288
    NmUiExtensionManager &extensionManager = mApplication.extManager();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1289
    if (&extensionManager) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1290
        QList<NmAction*> actionList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1291
        extensionManager.getActions(request, actionList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1292
        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
  1293
            mAttachmentListContextMenu->addAction(actionList[i]);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1294
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1295
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1296
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1297
    // 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
  1298
    QPointF menuPos(point.x(),point.y());
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1299
    mAttachmentListContextMenu->setPreferredPos(menuPos);
40
hgs
parents: 23
diff changeset
  1300
    mAttachmentListContextMenu->open();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
    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
  1305
    completed for one attachment.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1306
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1307
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
  1308
{
43
hgs
parents: 40
diff changeset
  1309
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1310
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1311
    if (result == NmNoError && mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1312
        // 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
  1313
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1314
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1315
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1316
        NmMessagePriority messagePriority = mMessage->envelope().priority();        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1317
        
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1318
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1319
        mMessage = NULL;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1320
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1321
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1322
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1323
        if (mMessage) {
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1324
            mMessage->envelope().setPriority(messagePriority);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1325
            mMessage->envelope().setHasAttachments(true);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1326
            // Get attachment list from the message
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1327
            QList<NmMessagePart*> attachmentList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1328
            mMessage->attachmentList(attachmentList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1329
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1330
            // Search newly added attachment from the list
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1331
            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
  1332
                if (attachmentList[i]->partId() == msgPartId) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1333
                    // 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
  1334
                    mHeaderWidget->setAttachmentParameters(fileName,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1335
                        msgPartId,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1336
                        QString().setNum(attachmentList[i]->size()),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1337
                        result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1338
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1339
            }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1340
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
        // Attachment adding failed. Show an error note and remove from UI attachment list.
43
hgs
parents: 40
diff changeset
  1344
        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
  1345
        mHeaderWidget->removeAttachment(fileName);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1347
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1348
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1350
    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
  1351
    completed totally.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1352
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
void NmEditorView::allAttachmentsAdded(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
{
43
hgs
parents: 40
diff changeset
  1355
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1356
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1357
    enableToolBarAttach(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1358
    if (result != NmNoError) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1359
        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
  1360
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1361
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1362
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1363
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1364
   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
  1365
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1366
void NmEditorView::setPriority(NmActionResponseCommand priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1367
{
43
hgs
parents: 40
diff changeset
  1368
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1369
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
    mHeaderWidget->setPriority(priority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1372
    if (mMessage) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
        NmMessagePriority messagePriority = NmMessagePriorityNormal;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1374
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
        if (priority == NmActionResponseCommandPriorityHigh) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
            messagePriority = NmMessagePriorityHigh;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1377
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
        else if (priority == NmActionResponseCommandPriorityLow) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
            messagePriority = NmMessagePriorityLow;
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
        mMessage->envelope().setPriority(messagePriority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
    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
  1388
    delimiter.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1389
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1391
    \return String containing the addresses.
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
QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
{
43
hgs
parents: 40
diff changeset
  1395
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1396
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
    QList<NmAddress*>::const_iterator i = list.constBegin();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
    while (i != list.constEnd() && *i) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1401
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1403
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1405
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1406
        addressesString += (*i)->address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1410
    return addressesString;
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
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
    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
  1416
    delimiter.
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
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1419
    \return String containing the addresses.
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
QString NmEditorView::addressListToString(const QList<NmAddress> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1422
{
43
hgs
parents: 40
diff changeset
  1423
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1424
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1426
    QList<NmAddress>::const_iterator i = list.constBegin();
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
    while (i != list.constEnd()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1430
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1431
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1432
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1433
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1434
        addressesString += (*i).address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1435
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1436
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1437
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1438
    return addressesString;
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
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1441
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1442
    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
  1443
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1444
void NmEditorView::removeAttachmentTriggered()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1445
{
43
hgs
parents: 40
diff changeset
  1446
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1447
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1448
    // Cancel will delete previous operation
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1449
    if (mRemoveAttachmentOperation) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1450
        if (!mRemoveAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1451
            mRemoveAttachmentOperation->cancelOperation();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1452
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1453
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1454
    // Remove from UI
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1455
    mHeaderWidget->removeAttachment(mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1456
    // Remove from message store
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1457
    mRemoveAttachmentOperation = mUiEngine.removeAttachment(*mMessage, mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1458
    if (mRemoveAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1459
        // Signal to inform the remove operation completion
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1460
        connect(mRemoveAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1461
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1462
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1463
                SLOT(attachmentRemoved(int)));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1464
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1465
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1466
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1467
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1468
    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
  1469
    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
  1470
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1471
void NmEditorView::attachmentRemoved(int result)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1472
{
43
hgs
parents: 40
diff changeset
  1473
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1474
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1475
    // 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
  1476
    Q_UNUSED(result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1477
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1478
    if (mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1479
        // 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
  1480
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1481
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1482
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1483
        NmMessagePriority messagePriority = mMessage->envelope().priority();    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1484
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1485
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1486
        mMessage = NULL;
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
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1489
        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1490
        if(mMessage) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1491
            // Set the correct priority
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1492
            mMessage->envelope().setPriority(messagePriority);    
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1493
            
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1494
            // If there is no more attachments in the message, set the correct value
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1495
            QList<NmMessagePart*> attachmentList;
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1496
            mMessage->attachmentList(attachmentList);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1497
            if(attachmentList.count() == 0) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1498
                mMessage->envelope().setHasAttachments(false);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1499
            }
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1500
        }
20
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
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1504
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1505
    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
  1506
*/
44
hgs
parents: 43
diff changeset
  1507
void NmEditorView::openAttachmentTriggered(NmId attachmentId)
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1508
{
43
hgs
parents: 40
diff changeset
  1509
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1510
    NmId mailboxId = mMessage->envelope().mailboxId();
hgs
parents: 43
diff changeset
  1511
    NmId folderId = mMessage->envelope().folderId();
hgs
parents: 43
diff changeset
  1512
    NmId msgId = mMessage->envelope().messageId();
hgs
parents: 43
diff changeset
  1513
hgs
parents: 43
diff changeset
  1514
    XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
hgs
parents: 43
diff changeset
  1515
    		msgId, attachmentId);
hgs
parents: 43
diff changeset
  1516
    int error = NmUtilities::openFile(file);
hgs
parents: 43
diff changeset
  1517
    file.close();
hgs
parents: 43
diff changeset
  1518
    if ( error == NmNotFoundError ) {
hgs
parents: 43
diff changeset
  1519
        NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); 
hgs
parents: 43
diff changeset
  1520
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1521
}
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
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1524
   Enables/disables toolbar extension for attach
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1525
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1526
void NmEditorView::enableToolBarAttach(bool enable)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1527
{
43
hgs
parents: 40
diff changeset
  1528
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1529
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1530
    HbToolBar *tb = toolBar();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1531
    if (tb) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1532
        QList<QAction *> toolbarList = tb->actions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1533
        int count = toolbarList.count();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1534
        for (int i = 0; i < count; i++) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1535
            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
  1536
            if (action->availabilityCondition() == NmAction::NmAttachable) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1537
                action->setEnabled(enable);
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
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1541
}